Skip to content

Commit a93449b

Browse files
author
Michael v/d Rijt
committed
Added the 'byValue' method
1 parent 5b66b22 commit a93449b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/Enum.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,18 @@ public static function search($value)
153153
return array_search($value, static::toArray(), true);
154154
}
155155

156+
/**
157+
* Return new instance by value
158+
*
159+
* @param $value
160+
*
161+
* @return static
162+
*/
163+
public static function byValue($value)
164+
{
165+
return new static($value);
166+
}
167+
156168
/**
157169
* Returns a value when called statically like so: MyEnum::SOME_VALUE() given SOME_VALUE is a class constant
158170
*

0 commit comments

Comments
 (0)