Releases: myclabs/php-enum
Releases · myclabs/php-enum
1.5.2
1.5.1
Bugfix in the equals()
method
Issue: #47
Pull request: #48
Contributed by @peter-gribanov
Example:
class CommandAction extends Enum
{
const EDIT = 'edit';
}
class AccessRule extends Enum
{
const EDIT = 'edit';
}
Expected
CommandAction::EDIT()->equals(AccessRule::EDIT()); // false
Actual
CommandAction::EDIT()->equals(AccessRule::EDIT()); // true
1.5.0
#4 #39 #40: new equals()
method to compare enums
$enum = MyEnum::FOO();
if ($enum->equals(MyEnum::BAR())) {
...
}
It behaves the same as ==
:
if ($enum == MyEnum::BAR()) {
...
}
It was added because it carries a bit more sense than ==
which, because it is a loose comparison, is often source of confusion (comparing objects with ==
is often a no-go for good reasons).
1.4.2
1.4.1
1.4.0
1.3.2
1.3.1
1.3.0
A bunch of new methods were added in #5:
$value->getKey()
Returns the key of the current value on EnumEnum::keys()
Returns the names (keys) of all constants in the Enum classEnum::isValid()
Check if tested value is valid on enum setEnum::isValidKey()
Check if tested key is valid on enum setEnum::search()
Return key for searched value
The library is now PSR-4 compliant.