Skip to content

Commit

Permalink
add SRV record support #1
Browse files Browse the repository at this point in the history
  • Loading branch information
ghost committed Dec 17, 2023
1 parent 0d84035 commit 60114e9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Dig.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ private static function _records(): array
[
'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
Expand Down

0 comments on commit 60114e9

Please sign in to comment.