public static function isValidDni(string $dni): bool
    {
        if (!preg_match(self::DNI_REGEX, $dni, $matches)) {
            return false;
        }
        if ('00000000' === $matches['number']) {
            return false;
        }

        return self::DNINIE_CHECK_TABLE[$matches['number'] % 23] === $matches['check'];
    }
public static function isValidDni(string $dni): bool
    {
        if (!preg_match(self::DNI_REGEX, $dni, $matches)) {
            return false;
        }
        if ('00000000' === $matches['number']) {
            return false;
        }

        return self::DNINIE_CHECK_TABLE[$matches['number'] % 23] === $matches['check'];
    }
public static function isValidDni ( string $ dni ) : bool { if ( ! preg_match ( self :: DNI_REGEX , $ dni , $ matches ) ) { return false ; } if ( '00000000' === $ matches [ 'number' ] ) { return false ; } return self :: DNINIE_CHECK_TABLE [ $ matches [ 'number' ] % 23 ] === $ matches [ 'check' ] ; }
DNI validation is pretty straight forward.
Just mod 23 the 8 digit number and compare it to the check table
DNI validation is pretty straight forward . Just mod 23 the 8 digit number and compare it to the check table