marc-mabe / php-enum

Simple and fast implementation of enumerations with native PHP
BSD 3-Clause "New" or "Revised" License
464 stars 36 forks source link

Add comparison function #35

Closed DmitryVarennikov closed 10 years ago

DmitryVarennikov commented 10 years ago

Does it make sense to add equals method for enum comparison? So we can actually pass a value to the equals method to compare current enum object against a scalar value, e.g.

// $post::getPrivacy return an instance of enum object
if ($post->getPrivacy()->equals('public')) // do smth...
marc-mabe commented 10 years ago

This sounds like a good idea as it doesn't require to parse both operators to be comparable. I would prefer the smaller method name is()

DmitryVarennikov commented 10 years ago

Yea, is sounds better, helps to avoid confusion about equal and identical terms for a weak-typed language as PHP is.

marc-mabe commented 10 years ago

closed by ab50cb784481e96c9f5362ddbb1bc9df2bb55fe2

DmitryVarennikov commented 10 years ago

Awesome, could you add 1.2.0 tag?

marc-mabe commented 10 years ago

@dVaffection I'll wait a little bit (1-2 weeks) so other improvements / bugfixes / meanings can go into

DmitryVarennikov commented 10 years ago

Maybe you can add a branch alias for 1.2.0 in your composer.json?

marc-mabe commented 10 years ago

@dVaffection done