public function isInCidrRange(string $cidrIpShort, $cidrMask): bool
    {
        if (is_string($cidrMask) && !ctype_digit($cidrMask)) {
            throw new \InvalidArgumentException(
                    'cidrMask must be of type int or a string losslessly'
                    . ' convertible to int.'
            );
        }

        list($lower, $upper) = $this->calculateIpRange(
                $this->completeCidrIp($cidrIpShort),
                (int) $cidrMask
        );
        return $this->asLong() >= $lower &&  $this->asLong() <= $upper;
    }
public function isInCidrRange(string $cidrIpShort, $cidrMask): bool
    {
        if (is_string($cidrMask) && !ctype_digit($cidrMask)) {
            throw new \InvalidArgumentException(
                    'cidrMask must be of type int or a string losslessly'
                    . ' convertible to int.'
            );
        }

        list($lower, $upper) = $this->calculateIpRange(
                $this->completeCidrIp($cidrIpShort),
                (int) $cidrMask
        );
        return $this->asLong() >= $lower &&  $this->asLong() <= $upper;
    }
public function isInCidrRange ( string $ cidrIpShort , $ cidrMask ) : bool { if ( is_string ( $ cidrMask ) && ! ctype_digit ( $ cidrMask ) ) { throw new \ InvalidArgumentException ( 'cidrMask must be of type int or a string losslessly' . ' convertible to int.' ) ; } list ( $ lower , $ upper ) = $ this -> calculateIpRange ( $ this -> completeCidrIp ( $ cidrIpShort ) , ( int ) $ cidrMask ) ; return $ this -> asLong ( ) >= $ lower && $ this -> asLong ( ) <= $ upper ; }
checks if IP address is in given CIDR range

A cidr range is commonly notated as 10.16/13. From this, $cidrIpShort
would be 10.16 and $cidrMask would be 13 or 47.

Please note that this method currently supports IPv4 only.

@param   string      $cidrIpShort
@param   int|string  $cidrMask
@return  bool
@throws  \InvalidArgumentException  when $cidrMask is not a valid integer
@see     http://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing#CIDR_notation
checks if IP address is in given CIDR range