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:----RoSggZYjjczxnsAn+Q6wO8KqOih9+EB40q1gkm0dLm2Mj9PMZz3jQgWSXc++fSmqL/1FQmi9ZaX/9IYhStUZQz+1n9qkFAom4CP7lVw6ADBKcxtm0cvrBY+6F7EBP1mBCuLtQHRWQNQ9VcxDCACb7cqIjBmQeqSaTHz+1K0hTIDv1AjJzNZRB2lkAuTkqImj2BnuHmH+4BvPkaqZhETWazmiRnIDc7B+bNPeE1O/a1nx0JqhniZ+h5KuPlNk+7c8tbHAWviJddrn1DZrkjrTxZsScg0m/8JfQU4wWOwqurdfXd9hKJTR/bndVuDquJ+6Eh128vnpPrHsavkrKu93mwfTCnE/ij8v6i++AfpCksaIszDGc4pEJVJrBxeddBoHqun4XZj4CQ48x60l9j10ANAJgC5d9IZ5tK3uPfREZ3VtFZy6qcmXCBJcEcEthaW2g+bLo6G7D+MIHmwr0rm5rol+3Hl0Zwk7QsFHHkYQSH+CCp47EkHLMuaBsBrR3o8l87PT69XlAPZ4yx7StgYw0P8M2t1DJUOtwvUg8Ao/Uw3QYeSNnR9tV9YcYsM8uIxnFv/8hkrw+ULpRxaZWLm2EalPxAZ/0cX7ggTjs2G/IcpxI7k2iRR6znkaqXQfvnNgZfi/cG8EcfTQveXlHTfwJDPGZsThBs+WHS94eTP59fw=----ATTACHMENT:----MjI1MzE0MDQwODQyMTk2NiA3MTA0MjgxOTc0ODg3NjMgODAwNDcyNTMxNTIyNTIz