Created
April 14, 2025 09:42
-
-
Save capricornusx/f99b4b41bfa4ee8f6e458fc7fc23fb67 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
namespace App\Infrastructure\Doctrine\Type; | |
use Doctrine\DBAL\Platforms\AbstractPlatform; | |
use Doctrine\DBAL\Types\Type; | |
class InetType extends Type | |
{ | |
public const TYPE_NAME = 'inet_type'; | |
public function convertToDatabaseValue(mixed $value, AbstractPlatform $platform): ?string | |
{ | |
if (!filter_var($value, FILTER_VALIDATE_IP)) { | |
return null; | |
} | |
return $value; | |
} | |
public function getName(): string | |
{ | |
return self::TYPE_NAME; | |
} | |
public function requiresSQLCommentHint(AbstractPlatform $platform): bool | |
{ | |
return true; | |
} | |
public function getSQLDeclaration(array $column, AbstractPlatform $platform): string | |
{ | |
return 'inet'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment