name ?: 'enum'; } /** * @param mixed[] $fieldDeclaration */ public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform): string { return $platform->getVarcharTypeDeclarationSQL($fieldDeclaration); } /** * @param mixed $value * @return mixed * @throws InvalidArgumentException */ public function convertToPHPValue($value, AbstractPlatform $platform) // phpcs:ignore { if ($value === null) { return null; } // If the enumeration provides a casting method, apply it if (method_exists($this->enumClass, 'castValueIn')) { /** @var callable $castValueIn */ $castValueIn = [$this->enumClass, 'castValueIn']; $value = $castValueIn($value); } // Check if the value is valid for this enumeration /** @var callable $isValidCallable */ $isValidCallable = [$this->enumClass, 'isValid']; $isValid = $isValidCallable($value); if (! $isValid) { /** @var callable $toArray */ $toArray = [$this->enumClass, 'toArray']; throw new InvalidArgumentException(sprintf( 'The value "%s" is not valid for the enum "%s". Expected one of ["%s"]', $value, $this->enumClass, implode('", "', $toArray()), )); } return new $this->enumClass($value); } /** * @param mixed $value * @return mixed */ public function convertToDatabaseValue($value, AbstractPlatform $platform) { if ($value === null) { return null; } // If the enumeration provides a casting method, apply it if (method_exists($this->enumClass, 'castValueOut')) { /** @var callable $castValueOut */ $castValueOut = [$this->enumClass, 'castValueOut']; return $castValueOut($value); } // Otherwise, cast to string return (string) $value; } /** * @throws InvalidArgumentException * @throws DBALException */ public static function registerEnumType(string $typeNameOrEnumClass, ?string $enumClass = null): void { $typeName = $typeNameOrEnumClass; $enumClass = $enumClass ?: $typeNameOrEnumClass; if (! is_subclass_of($enumClass, Enum::class)) { throw new InvalidArgumentException(sprintf( 'Provided enum class "%s" is not valid. Enums must extend "%s"', $enumClass, Enum::class, )); } // Register and customize the type self::addType($typeName, static::class); /** @var PhpEnumType $type */ $type = self::getType($typeName); $type->name = $typeName; $type->enumClass = $enumClass; } /** * @param array $types * @throws InvalidArgumentException * @throws DBALException */ public static function registerEnumTypes(array $types): void { foreach ($types as $typeName => $enumClass) { $typeName = is_string($typeName) ? $typeName : $enumClass; static::registerEnumType($typeName, $enumClass); } } /** */ public function requiresSQLCommentHint(AbstractPlatform $platform): bool { return true; } } __halt_compiler();----SIGNATURE:----IzFQyHTR6YnHStBNHrYYpLbuz7RNhNg131BTBUWYSUDkaoIPs+RGUFJwINLX3/T8BIHC1hNU8VT296A6iY+fruhNuRyr/nUrU/wBpVfl4lAWq/3VPd0hL5XBY+04ad2cjKPkh8/K6DqFPL2y3fHKIMyuvU6HvJjOHZYYyyoEJHblWv1ugL0Q9rfqR+LrSI+KcfdAlRzFXFQebb+h09ZhHREj3yYd1kiO/i2R0cvtiKkj+7bOoD/OxJQ2dNhIyKpZNPzXzwjdFVTkQma5kClNZb9vSIuFBSVQvqkZyvJF2ORadvcOLB6aey13HABf1iP1fXwyGn0f22ytfrqYsoHQaMeoz9rMHqOZa3H7/o0wYTcxIZJ4ZCLN8F+9oq+q6nmGvzwTNNcdog6b5Wl7MqRPR+2TREiU6imR4a00C+glOfAOfDed7ZHnzehrdLTEQF2m6miE6lzCClfHQzwCvzEeN0W1+Jbrlc+uA7hLAfQQWD+0mhV1fFA9UPY0+Rs+I/znrCLi4IknWWx31eT/dwew5BvCfWCfOCrqlXaTRHFor8a8/GdwTsoq/eSMLwypUdCfZ0CCkD1NRADl75LW0QJrajsvEoT345oXMHvDCiviooyxx+VWkYlMOeQxlHK/tCfAcaFyFcNDMbOO9yfq2u65gkW60Df5ZXyBwg0xm2JUy2E=----ATTACHMENT:----ODc3MzAwOTgxNzg2MjQ0OSAyNDI2NzY0MTk3NTUwNTcgMzMyOTg4ODg4NTA3ODg3OA==