ClassLoader::add( string $prefix, string[]|string $paths, bool $prepend = false )

Registers a set of PSR-0 directories for a given prefix, either appending or prepending to the ones previously set for this prefix.


Parameters Parameters

$prefix

(string) (Required) The prefix

$paths

(string[]|string) (Required) The PSR-0 root directories

$prepend

(bool) (Optional) Whether to prepend the directories

Default value: false


Top ↑

Return Return

(void)


Top ↑

Source Source

File: libraries/lifterlms-cli/vendor/composer/ClassLoader.php

    public function add($prefix, $paths, $prepend = false)
    {
        if (!$prefix) {
            if ($prepend) {
                $this->fallbackDirsPsr0 = array_merge(
                    (array) $paths,
                    $this->fallbackDirsPsr0
                );
            } else {
                $this->fallbackDirsPsr0 = array_merge(
                    $this->fallbackDirsPsr0,
                    (array) $paths
                );
            }

            return;
        }

        $first = $prefix[0];
        if (!isset($this->prefixesPsr0[$first][$prefix])) {
            $this->prefixesPsr0[$first][$prefix] = (array) $paths;

            return;
        }
        if ($prepend) {
            $this->prefixesPsr0[$first][$prefix] = array_merge(
                (array) $paths,
                $this->prefixesPsr0[$first][$prefix]
            );
        } else {
            $this->prefixesPsr0[$first][$prefix] = array_merge(
                $this->prefixesPsr0[$first][$prefix],
                (array) $paths
            );
        }
    }

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.