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

Allow enum clone #84

Closed zajca closed 7 years ago

zajca commented 7 years ago

Allow clone enum. This will allow to use enum with fixtures generators.

bm13kk commented 7 years ago

if it only for tests - reflection can be used

zajca commented 7 years ago

I'm using Alice fixture generator https://github.com/nelmio/alice which will do clone by default. this is what I'm doing most of the time:

EntityClass:
    name_{1..10}:
       type: <randomElement(<(MyTypeEnum::getEnumerators())>)>
marc-mabe commented 7 years ago

@zajca enumerators are not clonable as every enumerator should exist only once.

Also I don't really get your point of using a faker library to get enumerators as they are fixed defined by your enumeration. But as workaround you could use the enumerator values and later get the instance by value if you require the instance.