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:----GSkG6NjHaeUKmKhV7F5P9DWNFsizWe0ZBB+8+xq8VDRGu/n/fVpIyJz7eCe6xgJiMDq/1w5anfKJWeOETPHhj+boT3qAz9Zjm+gXRJEXBLqyWjpqbVlN7DJrnIOKEeDzYPwWuO0h3PqZ14+u+eMGUU0L8g4BKwgVqd5yX6ambxmbBAB1jab3wNms7JyZsEAhi/TE8UjZa3Yx6r9KrkabNanndrzwENJe/O9plakKIFB05Jy+dP2ZtfLkknh8IEy/2ugP7YBmnPW5oKtkH6jwPYrwaJwESSLwH6UIHauib272bkCtjJUBJYmSaqUtvQmgygZGDOdOtt2ICrQJelxvZILo7NVrIdEwt/pLfO+qLH3alUmHcB/a9jxDZ8vQbaKyhS0QiBgGYeBuukm7qXvGqAkXR0NS9uufZAR1LP4+yLP0KgbE0YVwX0khfzweyK/WKMsTjL2rp905+rVsk3SGjyNv1saV+MNoPzku6k43icMJ5ZWNlreeAKhPvAzzU/g/3SqEXyV53ypPobzek0R3ux0pynreC9c6tlIGMunLwlwlKZSsyaVuYrlUHmqoX3PjtLTudZCsbIq6t761EX2sDuKs8l3MSUADvLlRBu5j5kGWjWQG9xuuaT7HYmhe9b1xfmKr9ai2pp6Bo9YgRfrZPx175xTXPtzrds6uCyaJZO4=----ATTACHMENT:----NjAxNTc0NTMzNDM5MDI4OSAyMzI4ODQxMDgyMDU3MDA4IDYwMzU4Nzc3OTE5MDIxMzk=