MyCLabs\Enum\Enum::__construct PHP Метод

__construct() публичный Метод

Creates a new value of some type
public __construct ( mixed $value )
$value mixed
    public function __construct($value)
    {
        if (!$this->isValid($value)) {
            throw new \UnexpectedValueException("Value '{$value}' is not part of the enum " . get_called_class());
        }
        $this->value = $value;
    }

Usage Example

Пример #1
0
 public function __construct($value)
 {
     try {
         parent::__construct($value);
     } catch (\UnexpectedValueException $e) {
         throw new InvalidArgumentException($value, $e);
     }
 }