You are here

public function ClassLoader::setPsr4 in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/composer/ClassLoader.php \Composer\Autoload\ClassLoader::setPsr4()

Registers a set of PSR-4 directories for a given namespace, replacing any others previously set for this namespace.

Parameters

string $prefix The prefix/namespace, with trailing '\\':

array|string $paths The PSR-4 base directories:

Throws

\InvalidArgumentException

File

vendor/composer/ClassLoader.php, line 218

Class

ClassLoader
ClassLoader implements a PSR-0 class loader

Namespace

Composer\Autoload

Code

public function setPsr4($prefix, $paths) {
  if (!$prefix) {
    $this->fallbackDirsPsr4 = (array) $paths;
  }
  else {
    $length = strlen($prefix);
    if ('\\' !== $prefix[$length - 1]) {
      throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
    }
    $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
    $this->prefixDirsPsr4[$prefix] = (array) $paths;
  }
}