Пример #1
0
 /**
  * Construct enum data type.
  * @param string|string[] $valuesOrClass Either an enum class or a list of
  * enum values.
  * @param string $null Is nullable.
  * @param string $default Default value.
  * @throws InvalidEnumException If default values is not part of enum.
  */
 protected function __construct($valuesOrClass, $null = false, $default = null)
 {
     parent::__construct(DataType::ENUM, $null, $default);
     if (is_array($valuesOrClass)) {
         $this->values = $valuesOrClass;
     } else {
         $this->class = $valuesOrClass;
         $this->values = Enum::getValues($this->class);
     }
     if (isset($default) and !in_array($default, $this->values)) {
         throw new InvalidEnumException(tr('Default value must be part of enum'));
     }
 }