From 8eba81ae5f718c97c32ad62bcd131ed9d14d7061 Mon Sep 17 00:00:00 2001 From: ghost Date: Sat, 16 Dec 2023 14:51:48 +0200 Subject: [PATCH] allow mixed data type values for IS methods --- src/Dig.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Dig.php b/src/Dig.php index 00e2100..367c8a2 100644 --- a/src/Dig.php +++ b/src/Dig.php @@ -16,19 +16,21 @@ class Dig ]; } - public static function isHostName(string $hostname): bool + public static function isHostName(mixed $value): bool { - return false !== filter_var($hostname, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME); + return is_string($value) && false !== filter_var($value, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME); } - public static function isRecord(string $record): bool + public static function isRecord(mixed $value): bool { - return isset(self::_records()[$record]); + return is_string($value) && isset(self::_records()[$value]); } - public static function isRecordValue(string $record, string $value): bool + public static function isRecordValue(mixed $record, mixed $value): bool { - return isset(self::_records()[$record]) && self::_records()[$record]($value); + return is_string($record) && + is_string($value) && + isset(self::_records()[$record]) && self::_records()[$record]($value); } public static function records(string $hostname, array $records, array &$result = [], array &$error = []): array