From 60114e9d1e19731b79b7a0de7824164d7a288d7e Mon Sep 17 00:00:00 2001 From: ghost Date: Sun, 17 Dec 2023 07:59:26 +0200 Subject: [PATCH] add SRV record support #1 --- src/Dig.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Dig.php b/src/Dig.php index 367c8a2..7323f0c 100644 --- a/src/Dig.php +++ b/src/Dig.php @@ -12,13 +12,14 @@ class Dig [ 'A' => function(string $value): bool {return false !== filter_var($value, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4);}, 'AAAA' => function(string $value): bool {return false !== filter_var($value, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6);}, + 'SRV' => function(string $value): bool {return (bool) preg_match('/^[\d]+\s[\d]+\s[\d]+\s[A-z0-9-\._]+$/', $value);}, // ... ]; } - public static function isHostName(mixed $value): bool + public static function isHostName(mixed $value, array $find = ['_'], array $replace = []): bool { - return is_string($value) && false !== filter_var($value, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME); + return is_string($value) && false !== filter_var(str_replace($find, $replace, $value), FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME); } public static function isRecord(mixed $value): bool