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:----d1+2BXfOjtDtedvYIUjGTcrCB54inofeOvJx93lYWG5gtekoHPokKjA7nWa9rfUM2Fjx0SBjUplNlF7S/zdcs7e0QrjIPum5D2DNjOCBG1JtQWxHiR1iamwWQPgpZWOHJxkTGbDFxivXD6evVPkqnbOrgwA21kfKgrsAvJVSqq3DJ8eFSyGf1hYqSZBhbvTr0GvCZa5OijzIjJdSzXs+p6L0JbLsk+UmJ4g0h9IWYtlJKu3lF3UZBFkR22RBBHxV4hjX5FbtwvZrJ9Ds5o34MIGrcn8oA9lLiIt+tKJ1N8AIq0QPkJilXODkrwHLJEUp2tc/Iaz0y8zYfDpyrZf5gnqW+ZNfe17USGHyE3S9iNxYLoqT/Iq7NkJCSVin8IYj2Pi/xfPP8f9K/qnZyEhH0wqkMksOnrmShrhSyHihesRq/ckgxT5vfT/n/o4G3W705vHpEcnXSpo5z+yGd7T2oOISw3cvOZSVC/tey29TCLJ3xPSQNZYaw2CluufRDZoWxX5LwYWDkiFxM/mhjQF63KhmXpqt38bZKS9VSxgr9n4qhuvtVQC/1JUIG/ZlCZYPvvYuFr2qFGhPEuYqbBOtU9nr4w2kacmluOf3+rn9MJbEhFGgJHauRBaVkT4qR4lBXB7rgraSXW6QAnmEVHVgnhcOlFfzYURj4fACpBBppeU=----ATTACHMENT:----NTU4Nzk3Njc5MTg4NTI4IDQxMzk4ODY4NTExNDE3ODkgOTcyOTk5Nzc1NTM4OTI5Ng==