public static function isValidNie(string $nie): bool
    {
        if (!preg_match(self::NIE_REGEX, $nie, $matches)) {
            return false;
        }

        $nieType = strpos(self::NIE_TYPES, $matches['type']);
        $nie = $nieType . $matches['number'];

        return self::DNINIE_CHECK_TABLE[$nie % 23] === $matches['check'];
    }
public static function isValidNie(string $nie): bool
    {
        if (!preg_match(self::NIE_REGEX, $nie, $matches)) {
            return false;
        }

        $nieType = strpos(self::NIE_TYPES, $matches['type']);
        $nie = $nieType . $matches['number'];

        return self::DNINIE_CHECK_TABLE[$nie % 23] === $matches['check'];
    }
public static function isValidNie ( string $ nie ) : bool { if ( ! preg_match ( self :: NIE_REGEX , $ nie , $ matches ) ) { return false ; } $ nieType = strpos ( self :: NIE_TYPES , $ matches [ 'type' ] ) ; $ nie = $ nieType . $ matches [ 'number' ] ; return self :: DNINIE_CHECK_TABLE [ $ nie % 23 ] === $ matches [ 'check' ] ; }
NIE validation is similar to the DNI.
The first letter needs an equivalent number before the mod operation
NIE validation is similar to the DNI . The first letter needs an equivalent number before the mod operation