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

Implement [get|set]Ordinal() #4

Closed marc-mabe closed 11 years ago

marc-mabe commented 11 years ago

as noted in #1

It should be possible to change the value by it's enum position - I'm not sure if setOrdinal() is a good name for it.

prolic commented 11 years ago

setOrdinal() for setting by position? not really ;-)

$enum->setValueByOrdinal(2) - does that sound better? not really again.

On the other hand, I am thinking about removing the setValue and setName methods, too. An enum should be immortal. If you need another one, create a new enum.

marc-mabe commented 11 years ago

After some considerations I agree with you. an enum itself defines a value and it that value is modifiable it could be much harder for other to detect changes because the object itself didn't change.

So I agree for removing setters ... I will create an issue