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:----YMveE2TeEjgsLoJXTmyZ2e2Vi6AiKieoepckgyKQZg6qFxqm5CCOsz6gZvHqthIk5uc/e3icY7nogOa2xWDDds3fn1UitOWRlnXnoWDQq6+CkdRnQSEORv+WCSnq1eJ2UF4uCN9KsUWBty8cJmi+5ljPsU8v5Dn0oZdr8Aq7SsX3qTFLulMHY9CITCb9PgkIVoO/PQ1IHDsPVWlCBhD/Dc3+jMdf3hMbd7+S9KiCzkV3avE9q2ubwMkP+ddcwYxdEYho1T9DlqfLntOhQmW5G3FzEKwS7YcayqC166ww6NmiaabaqzDSHELayQy/Z3Y85aF870Si3JPblgw/TYwbasY8Vr7+2JstSB0b7eypqMKUIxliqdBOUIKXFQz2ZIQxZNK6VjmNrnPakVhMbZhii967VChrOyJuG39VByEARXOvysLWmfu7vndAb/Oxw0BFsCjN4QVXB/+bfE/U3dXdTk903TPMjpqxv2M0D7inq5UY4UrLKuL8ciDZ+wWdjMRB/ictTXZxSHD86Sgk+n/SEnMjx7HwFV3o2U50o6T3AQayXuv9yZBLbFzTfwNUVWJOudxW5GjlyqUSlyDM/FNlraBYbagyjTgsmBYdbSWfQpisKK34kz1wH1uHXdsoSS9NJSFNQmIyGfz1qgUyYvx49g6Xt3WzqoI6SNnq8g4YXM0=----ATTACHMENT:----MTYzNDAxMzIyMzY0MzgxNSA1NDQ5MTQ3MDU0NDYxNDc2IDM5ODMxMDI3NDU3NTYyMTg=