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:----AO1fqnWtYpnbchdTAugh4N12WzPWn4GZB04909RAW2Y05ZSTwzT+sQkMvxl9ANH0B80KARRsPM7UWf+6DQry82vUeiktT1qNcm+br0eSRl/CMrUWBKpVbZae46Z9WWV48vM7AfPw31aDz4O7uClIS4oQO9SlUIKS8uPp2QfOwB62GYCTFzdeMq1M+kxZHUz2IKGTcfJo58ljP52tXpnIZrDQ3868Lu4okZrXI/Ivd9bIa6enJ+SerKOcIeKsvT2NHfMYJcLclkbN8w/iY98oatQAy65YSX0joOnlg1QIcktWFJAfO4+ZY+gugnw1bLqO2cbuurgggniE+IDwz+hiumKyQ2X5bwwiY7DJRcibJyVa6Df1mrl3IXsItI48TXD6B50V5MoG03js+oodfTN5+R/rmTN3VM5ApBIaHorPVgeFcJ1cNkfuHVW+P2EREMsWARs2FG88MRKYU1B+YGgdOE42ikaktqjB9QPQif4P6vxMqIPwOYcwpCW4fZ5Z5a3Fga6sghVObaVA1Eb1K1zyZqIoWAtb8d0m7YegejqfnqDaPYoeAij9DXNvwB2vryMgJfUm9E+9ZQDtGKd6BH18Dn4pGIVT1oR6ACgdc31MZlYWZVYGcxlHIF4sdNowwJyL0BzlFb/NhNUzwhGzrOMaiLJer2dVMh72NSgKy4EH5To=----ATTACHMENT:----OTM1MzIzMjA1NTgyODUxOCAzMTIxNDQ4Mjk5NTY4NTU2IDkzOTY4ODU5ODY3NTU5OTA=