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:----raYJVM0Wjz7ZtGJXeMX1yEZm1LWJCXUq06pGq5saeNucwI5yuz15Fxc0jZboes4G6UGHEBKU+D6kRu4XDH5v+2TGAIe3Tsayk9ZozAB3CRg6zXy+cLse5Vapb9xZ3fgToBIefuc/91qLdW5kSS7aEEi6NOTMGPGBm1S0NB4QCqa2kOImH76K5ivVWNBKhWK0VHYi+auv1riPovscC7484C6ujBm/cwowG53tPf3PMPzs64FYs7Zv7RG6rbyLCUo7f9U/NkVhCzYT9zNahl28Lp40CAAxg9wJNB34EBUOgO1A+rKUnMD7ga/c+0+GNAW2WiYjFKMvHl4H0wkwwHawfM0vGLkxa1iEnzabxgBp3ANu6ejdGWHglyg1KnNWF6bqDvQPZ0KaMMx+crSDFV9eQgCVcM4wssOemFg/ho3ySt77EXSleV1e4J1XUryGduhRmYDqCI/pLaSWx456FL9kWi6d0C2WRxocTcOwhd8FW1UVxNTQLqqTxsHuYzLaKOo7kCq/5jD/8O+LEDEdgPtca59X4I2HBa/+dk3Q08ZcUQ5fIE/t8hTVeievBjU9wjiLnMbrxY7RV2skkcH/uCvmBOrozigoUyPwJB59B6agoFm6PNSmxloIQbBcnPvh27anPcUjNPw6pR6JiS0hFw6IXIZM779U4A3pG1BRJt39sYc=----ATTACHMENT:----NTY3MDE2MjM1OTEzNDk1NyA1MDk0MzM0MDEzOTkyNzEyIDQ1OTg4ODI0ODA4NzUxMDA=