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:----CkTv+lFKCjQKVBqjXj07YDLCe3/yUM7LMaGkCuktSI374Fv2fZ8GQ3mZF+fuRp2F/Rl5UDgKmZF+kFveEtLhN+K/EgNl9kYrkYlBHLtHrAwCLd/boHlE8QOEdx9oqN7SzlQ5fzq9jWMONBvZKNJhwZmWnn+eqpE14pxpn4L3R8JosrcZIYFnBbGFkkillgEqjTPYoELEQyfRdNqu9OxxDNEzcf/i8uQLyf7ml8O09vP2WXy1zkkaI6xq4fyCSZ6Ebobf0+RPpUIENew1mcbY0qS2ITJYxgNiq79kS/GQYBkViFFOxMfAUjMSc0RGaACe+eGQs67HxfH24NPTRRfx2BpKxiYeT8rz99uSiLQJK2qLK28MO2oY/x5hRW4XjpfcNaCJLBpI2Qwjkau/kjGaFB4bflx6do7s6IKyhQmwvSmkF4SaQGfn8aNCL89MJrSluXVKSmQ7IxLWPfOqa1xb3X85hqNRGZPINCJLR7lphcXeBJtEG2QI2PhJxf+ZSKbRVZ3/o2IbKbia7sLT9lO7otVPemzhnH/yywhMBch14o1Fk06EE7ELNZHEheLfevn2Z518Wy++HLXcyqd9CT/CFJ1FQkFQLL+Jy1iYRpzyjzWkidwGC8kaBjq2UhSidTcB1GuTfM9+mBVkAWMnAuRiv8e/+gb6U3tlpUafKXkjLqw=----ATTACHMENT:----NTk5ODQ3MTk4NjYyNTM1NiA4MDgyNTQ2MjE5MDQ1ODcxIDg5NTQzMjE4ODY2MDkwMDI=