hasCase($name)) // - если нет - ошибка throw new InvalidArgumentException(sprintf("Enumeration name '%s' does not exist!", $name)); try { $result = $reflection->getCase($name)->getValue(); } catch (ReflectionException) { $result = new static(); } return $result; } /** * Получает значение перечисления * * @return string Значение перечисления */ public function GetValue (): string { return $this->name; } /** * Конвертирует в перечисление из int. * * @param int $value Значение перечисления в формате int * * @return MessageType|EnumExtensionsTrait Объект * перечисления */ public static function FromInt (int $value): self { return self::tryFrom($value); } /** * Переводит тип в INT * * @return int Значение типа в INT */ public function ToInt (): int { return $this->value; } }