You are here

public function ClassLoader::setPsr4 in Mobile Number 7

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

include/ClassLoader.php, line 250

Class

ClassLoader
ClassLoader implements a PSR-0, PSR-4 and classmap class loader.

Namespace

mobile_number

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;
  }
}