mirror of
https://github.com/YGGverse/net-php.git
synced 2026-03-31 17:15:35 +00:00
fix validation
This commit is contained in:
parent
26315c924f
commit
a64b7ac816
1 changed files with 8 additions and 4 deletions
|
|
@ -21,11 +21,15 @@ class Socket
|
||||||
|
|
||||||
public static function isPort(mixed $value): bool
|
public static function isPort(mixed $value): bool
|
||||||
{
|
{
|
||||||
$length = strlen(
|
if (false === filter_var($value, FILTER_VALIDATE_INT))
|
||||||
$value
|
{
|
||||||
);
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return false !== filter_var($value, FILTER_VALIDATE_INT) && 0 < $length && 65536 > $length;
|
return
|
||||||
|
(
|
||||||
|
0 < $value && 65536 > $value
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function isOpen(string $host, int $port = -1, ?float $timeout = null, int &$error_code = null, string &$error_message = null): bool
|
public static function isOpen(string $host, int $port = -1, ?float $timeout = null, int &$error_code = null, string &$error_message = null): bool
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue