Skip to content

Instantly share code, notes, and snippets.

@auroraeosrose
Created August 18, 2012 17:03
Show Gist options
  • Save auroraeosrose/3388410 to your computer and use it in GitHub Desktop.
Save auroraeosrose/3388410 to your computer and use it in GitHub Desktop.
Enum Wrapper class - what do YOU think it outputs ;)
use G\Enum as Enum;
<?php
class Fruit extends Enum {
const Apple = 1;
const Pear = 2;
const Banana = 3;
}
$fruit = new Fruit(Fruit::Apple);
echo $fruit, PHP_EOL;
var_dump($fruit);
$fruit = Fruit::Pear;
echo $fruit, PHP_EOL;
$fruit = new Fruit(Fruit::Apple);
echo $fruit, PHP_EOL;
$fruit = 'Banana';
echo $fruit, PHP_EOL;
@auroraeosrose
Copy link
Author

1
object(Fruit)#1 (2) {
["__elements"]=>
array(3) {
["Apple"]=>
int(1)
["Pear"]=>
int(2)
["Banana"]=>
int(3)
}
["__value"]=>
int(1)
}
2
1
3

@auroraeosrose
Copy link
Author

Stupid markdown

1
object(Fruit)#1 (2) {
  ["__elements"]=>
  array(3) {
    ["Apple"]=>
    int(1)
    ["Pear"]=>
    int(2)
    ["Banana"]=>
    int(3)
  }
  ["__value"]=>
  int(1)
}
2
1
3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment