Skip to content

Commit

Permalink
Added the 'byValue' method
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael v/d Rijt committed Oct 15, 2015
1 parent 5b66b22 commit a93449b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Enum.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,18 @@ public static function search($value)
return array_search($value, static::toArray(), true);
}

/**
* Return new instance by value
*
* @param $value
*
* @return static
*/
public static function byValue($value)
{
return new static($value);
}

/**
* Returns a value when called statically like so: MyEnum::SOME_VALUE() given SOME_VALUE is a class constant
*
Expand Down

0 comments on commit a93449b

Please sign in to comment.