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:----hveG0IHT5sygt1bNeiunCThBVFaKQ5MnuMb2Vt8IBkFpBCUcJVzpG7wDRyLZlIL1CQPjlL1jo4sOw7I/9DFJBUxn/ylGVNptiLLo8Kl2OUMPe7Tjjw9izyzIffht+TibyUf+GEsLTptVipPU9KfqQrQ1pzd1TdTa3TKQDLGMwYEA9V7jIbPq9/0Zei03VLmwP5TbfKeme4WjCTeLwSuZi0W50JV9clsx4jnQjJL2dpM61kPcTw4yTvfSeSouHSUEvwZ+CmsywmD03OOoxe+NNZt2w702aM7d6M3/8HpYXrbwIr7WYcbN8GlCotrkyrrY+k6k++rn6TZJ4Po1mErP7+MnEGUPjMd99MiE4kk4X3M1rf2bnewZHGEIKxZMCfBPPQUy2XfmbnLnqSkBI4q4IW3cri+lW+3C1AvBQvsRW9oHZ7e2aSyKBePjoSSh8HgVHnOEchcFbI9VQ6CNJxb17ov1jgHgYp2hVIT/opvCwlkqOgFrdCHxf5DdDh5BmNM9dPX+rOhrxiTqw5GoXoQt9p9xUcaNmNTUtplESSLkZrc/WpovvnIo1AV2Yc3wrtXoDq+jQUoodI1DHc9S9BZo2dlXoPbZuMGSf5C0zloFhKxNJ75btywG2CUbBTkeqEvxWvp9Fkh+UPJf2CFZcSMOa/gJti0omOfQlOiX9cQpcf8=----ATTACHMENT:----ODI0MDU3MTcxMjY1MTc1MCA2NzgzNTMwODE5MzUyNzI1IDUwMDMxMzIxMTEwNDc0ODM=