You are here

public function ClassLoader::setPsr4 in Lockr 7.2

Same name and namespace in other branches
  1. 7.3 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 219

Class

ClassLoader
ClassLoader implements a PSR-0, PSR-4 and classmap 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;
  }
}