function addPrefix(string $prefix, $paths, int $type = self::PSR4): void
    {
        if ($type !== static::PSR4 && $type !== static::PSR0) {
            throw new \UnexpectedValueException('Invalid prefix type');
        }

        if ($prefix === '') {
            foreach ((array) $paths as $path) {
                $this->fallbacks[$type][] = $path;
            }

            return;
        }

        $firstNsSep = strpos($prefix, '\\');
        $prefixLength = strlen($prefix);

        // determine index
        if ($firstNsSep === false) {
            // no namespace
            if ($type === static::PSR4) {
                throw new \InvalidArgumentException(sprintf(
                    'PSR-4 prefixes must contain a top level namespace (got "%s")',
                    $prefix
                ));
            }

            // use first character
            $index = $prefix[0];
        } else {
            // has namespace
            if ($type === static::PSR4 && $prefix[$prefixLength - 1] !== '\\') {
                throw new \InvalidArgumentException(sprintf(
                    'PSR-4 prefixes must end with a namespace separator (got "%s")',
                    $prefix
                ));
            }

            // use vendor namespace
            $index = substr($prefix, 0, $firstNsSep);
        }

        // register
        $this->prefixes[$index][] = [$type, $prefix, $prefixLength, (array) $paths];
    }