54 ?\Closure $aliasMapper =
null
56 foreach($class::cases() as $case){
57 $int = $mapper($case);
58 $this->valueToEnum[$int] = $case;
59 $this->enumToValue[spl_object_id($case)] = $int;
61 if($aliasMapper !==
null){
62 $aliases = $aliasMapper($case);
63 foreach($aliases as $alias){
64 $this->valueToEnum[$alias] = $case;
80 public static function string(
string $class, \Closure $mapper, ?\Closure $aliasMapper =
null) : self{ return new self($class, $mapper, $aliasMapper); }
92 public static function int(
string $class, \Closure $mapper, ?\Closure $aliasMapper =
null) : self{ return new self($class, $mapper, $aliasMapper); }