Created
August 18, 2012 17:03
-
-
Save auroraeosrose/3388410 to your computer and use it in GitHub Desktop.
Enum Wrapper class - what do YOU think it outputs ;)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
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
1
object(Fruit)#1 (2) {
["__elements"]=>
array(3) {
["Apple"]=>
int(1)
["Pear"]=>
int(2)
["Banana"]=>
int(3)
}
["__value"]=>
int(1)
}
2
1
3