src/IPAddress.php
private static function myValidateIpAddressPart(string $ipAddressPart, ?int &$octet, ?string &$error): bool
    {
        if ($ipAddressPart === '') {
            $error = 'Octet "' . $ipAddressPart . '" is empty.';

            return false;
        }

        if (preg_match('/[^0-9]/', $ipAddressPart, $matches)) {
            $error = 'Octet "' . $ipAddressPart . '" contains invalid character "' . $matches[0] . '".';

            return false;
        }

        $octet = intval($ipAddressPart);

        if (!self::myValidateOctet($octet, $error)) {
            return false;
        }

        return true;
    }
private static function myValidateIpAddressPart(string $ipAddressPart, ?int &$octet, ?string &$error): bool
    {
        if ($ipAddressPart === '') {
            $error = 'Octet "' . $ipAddressPart . '" is empty.';

            return false;
        }

        if (preg_match('/[^0-9]/', $ipAddressPart, $matches)) {
            $error = 'Octet "' . $ipAddressPart . '" contains invalid character "' . $matches[0] . '".';

            return false;
        }

        $octet = intval($ipAddressPart);

        if (!self::myValidateOctet($octet, $error)) {
            return false;
        }

        return true;
    }
private static function myValidateIpAddressPart ( string $ ipAddressPart , ? int & $ octet , ? string & $ error ) : bool { if ( $ ipAddressPart === '' ) { $ error = 'Octet "' . $ ipAddressPart . '" is empty.' ; return false ; } if ( preg_match ( '/[^0-9]/' , $ ipAddressPart , $ matches ) ) { $ error = 'Octet "' . $ ipAddressPart . '" contains invalid character "' . $ matches [ 0 ] . '".' ; return false ; } $ octet = intval ( $ ipAddressPart ) ; if ( ! self :: myValidateOctet ( $ octet , $ error ) ) { return false ; } return true ; }
Validates an IP address part.

@param string      $ipAddressPart The IP address part.
@param int|null    $octet         The resulting octet.
@param string|null $error         The error text if validation was not successful, undefined otherwise.

@return bool True if validation was successful, false otherwise.
Validates an IP address part .