src/Utilities/Regex.php
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];
    }
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];
    }
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 ] ; }
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
Returns information if given NIP number is valid