public function addMap($prefix, $paths, $prepend = false)
{
if ($prefix) {
$prefix = ltrim($prefix, '\\');
}
if (!$prefix) {
// Register directories for the root namespace.
if ($prepend) {
$this->fallbackDirs = array_merge((array) $paths, $this->fallbackDirs);
$this->fallbackDirs = array_unique($this->fallbackDirs);
} else {
$this->fallbackDirs = array_merge($this->fallbackDirs, (array) $paths);
$this->fallbackDirs = array_unique($this->fallbackDirs);
}
} elseif (!isset($this->prefixDirs[$prefix])) {
// Register directories for a new namespace.
$length = strlen($prefix);
if ('\\' !== $prefix[$length - 1]) {
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
$this->prefixLengths[$prefix[0]][$prefix] = $length;
$this->prefixDirs[$prefix] = (array) $paths;
} elseif ($prepend) {
// Prepend directories for an already registered namespace.
$this->prefixDirs[$prefix] = array_merge((array) $paths, $this->prefixDirs[$prefix]);
$this->prefixDirs[$prefix] = array_unique($this->prefixDirs[$prefix]);
} else {
// Append directories for an already registered namespace.
$this->prefixDirs[$prefix] = array_merge($this->prefixDirs[$prefix], (array) $paths);
$this->prefixDirs[$prefix] = array_unique($this->prefixDirs[$prefix]);
}
return $this;
}