Returns information if given NIP number is valid

@param string $nip A given NIP number
@return bool

@see https://pl.wikipedia.org/wiki/NIP#Znaczenie_numeru
426379
public static function isValidNip($nip)
    {
        $nip = preg_replace('/[\D]/', '', $nip);

        $invalidNips = [
            '1234567890',
            '0000000000',
        ];

        if (!preg_match('/^[\d]{10}$/', $nip) || in_array($nip, $invalidNips, true)) {
            return false;
        }

        $sum = 0;
        $weights = [
            6,
            5,
            7,
            2,
            3,
            4,
            5,
            6,
            7,
        ];

        for ($i = 0; $i < 9; ++$i) {
            $sum += $weights[$i] * $nip[$i];
        }

        $modulo = $sum % 11;
        $numberControl = (10 === $modulo) ? 0 : $modulo;

        return $numberControl === (int)$nip[9];
    }
723620
public static function validateIP($ip) {
        if (strtolower($ip) === 'unknown')
            return false;

        // generate ipv4 network address
        $ip = ip2long($ip);

        // if the ip is set and not equivalent to 255.255.255.255
        if ($ip !== false && $ip !== -1) {
            // make sure to get unsigned long representation of ip
            // due to discrepancies between 32 and 64 bit OSes and
            // signed numbers (ints default to signed in PHP)
            $ip = sprintf('%u', $ip);
            // do private network range checking
            if ($ip >= 0 && $ip <= 50331647)
                return false;
            if ($ip >= 167772160 && $ip <= 184549375)
                return false;
            if ($ip >= 2130706432 && $ip <= 2147483647)
                return false;
            if ($ip >= 2851995648 && $ip <= 2852061183)
                return false;
            if ($ip >= 2886729728 && $ip <= 2887778303)
                return false;
            if ($ip >= 3221225984 && $ip <= 3221226239)
                return false;
            if ($ip >= 3232235520 && $ip <= 3232301055)
                return false;
            if ($ip >= 4294967040)
                return false;
        }
        return true;
    }
500291
public function validatePort($port = null)
    {
        if ($port === null) {
            $port = $this->_port;
        }

        // If the port is empty, then it is considered valid
        if (strlen($port) === 0) {
            return true;
        }

        // Check the port against the allowed values
        return ctype_digit((string) $port) and 1 <= $port and $port <= 65535;
    }
1262671
public function isValid($value)
    {
        if (!is_numeric($value)) {
            $this->_error(self::INVALID);
            return false;
        }

        $this->_setValue($value);
        $value = (float) $value;
        if ($value < 0 || $value > 1) {
            $this->_error(self::NOT_VALID);
            return false;
        }

        return true;
    }
601525
protected function validate(string $input): bool
    {
        return preg_match($this->realNumber ? self::REAL_NUMBER_REGEXP : self::INTEGER_REGEXP, $input) === 1;
    }
600538
public function validate($input): bool
    {
        if (\is_array($this->haystack)) {
            return \in_array($input, $this->haystack, false);
        }

        if (!\is_string($this->haystack)) {
            return false;
        }

        if (empty($input)) {
            return false;
        }

        $enc = mb_detect_encoding($input);

        return mb_stripos($this->haystack, $input, 0, $enc) !== false;
    }
162582
public static function isValid($port)
    {
        $port_valid = false;

        if (is_int($port)) {
            $port_valid = self::portIsInValidRange($port);
        } elseif (is_null($port)) {
            $port_valid = true;
        }

        return $port_valid;
    }
27467
public function validate($input) {
        if (is_integer($input)) {
            return $this->validateMax($input) && $this->validateMin($input);
        }
        return $input == intval($input) && $this->validateMax($input) && $this->validateMin($input);
    }
989114
protected function validaCEP($cep)
    {
        $formated_cep = preg_replace("/[^0-9]/", "", $cep);
        if (!preg_match('/^[0-9]{8}?$/', $formated_cep)) {
            throw new \Exception("CEP inválido");
        }
        $this->cep = $formated_cep;
    }
476085
public function isValidImplementation ($implementation)
	{
		if ($implementation == 'n/a')
		{
			return true;
		}
		
		if ($implementation == 'all')
		{
			foreach ($this->_implementations as $imp => $value)
			{
				if ($value == false)
				{
					return false;
				}
			}
			
			return true;
		}
		
		if (array_key_exists($implementation, $this->_implementations))
		{
			return $this->_implementations[$implementation];
		}
		
		return false;
	}
1120792
private function validateParameter(string $parameter): bool
    {
        $properties = explode('=', $parameter);

        return 2 != count($properties) || strtolower($properties[0]) === static::BINARY_PARAMETER;
    }
520207
public function isValid($answer)
    {
        // Compare shouldn't be strict, since we might compare a string against a number
        if ($this->storage->get() == $answer) {
            return true;
        } else {
            $this->error = 'Invalid answer provided';
            return false;
        }
    }
350506
protected function validatePointValue($point)
    {
        switch (true) {
            case ($point instanceof AbstractPoint):
                return $point->toArray();
                break;
            case (is_array($point) && count($point) == 2 && is_numeric($point[0]) && is_numeric($point[1])):
                return array_values($point);
                break;
            default:
                throw new InvalidValueException(sprintf('Invalid %s Point value of type "%s"', $this->getType(), (is_object($point) ? get_class($point) : gettype($point))));
        }
    }
238250
public function isValidRealNumber($v) : bool
    {
        return (  (is_int($v) === true || is_float($v) === true) || 
                  (is_string($v) === true && is_numeric($v) === true) || 
                  ($v instanceof RealNumber) );
    }
1074692
protected function validateMethod( $method ){
		if( !is_int( $method ) )
			throw new \InvalidArgumentException( 'Method must be integer' );
		if( !in_array( $method, array( self::METHOD_SOCKET, self::METHOD_PING ) ) )
			throw new \RangeException( 'Invalid method' );
		return $method;
	}
1012317
public static function isIp($ip)
    {
        $segments = explode('.', $ip);

        if (count($segments) === 4) {
            foreach ($segments as $segment) {
                if (!is_numeric($segment)) {
                    return false;
                }
            }

            return true;
        } else {
            return false;
        }
    }
954204
public function isValid()
    {
        return ((!empty($this->hex) && ctype_xdigit($this->hex)) && (!empty($this->dec) && ctype_digit($this->dec)));
    }