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) { 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:----StjHmLDgbYUoh7Pz7LVybsTLe8aa7yRvEiu/FpzywB6/mL0F0UIEwU65xrI/LFZwDB3hmZrJ+YYverWXXG/c7ZEKHPcKxNrFyof5cTY3FIfI8o927YtWTd9I00BUHt0GW574PWME0YOAZScCoXvfBuLb1OFpttrnVwTyel/U7uT6zDLcpPHlrGKNdefawMZKBF6Zs10IgssZWNpTFcyXJhPKxfu9KgN7g+kEQTDAlV6pSMeIeSR+c7/7e4/GRpDNUcyHLTqV8QHofTTqd1SBPPk1t4/RdCKgrQQvrmjs5T1HQFy2ibIFPzMILqtg5UgzgK5zywfHSQSDqjvPilHVGtwfTlH/NW8ZR0u7BeSo8+eYTNH0lrH8zR9ZwQB0+cpj6NCyyhCprmI5/RTVh6+OXnm8ab/XSEHYKDWP4gT21WU6HcyJ2Bagir05ovI5XURdDNx2MIk3NMDrmAcpuTnxVdYfaQ/bw920lRMJqOClxaL+VhNsAYzKPUOb5rgWYnMVJC//KHd6fs07pB5q83oHv5+VvXkz7V8cfWB7+vAYqq/9qzryZRXs8RTsZeukbk19pDvLsaa3ftuxFs9Gojlgns7wXy+6Dcfw5TY+URMCIx7+Za/uI8ot0eo4twyX5m/udju9+rYQs3u993rWZ/5M8G0Kidm1NcW0XqZ20Q3CzDE=----ATTACHMENT:----Njc1Njc3NDQxOTk4NjE0OCA3MzI2MzIzMzU5OTE0NjgyIDE2MjkyMDkxNTM1MTU5MA==