$directory) { // When adding new namespaces to the mappings, we will unset the previously // mapped value if it existed. This allows previously registered spaces to // be mapped to new directories on the fly. $namespace = trim($namespace, $append).$append; unset(static::$namespaces[$namespace]); $namespaces[$namespace] = head(static::format($directory)); } // We'll array_merge the new mappings onto the front of the array so // derivative namespaces are not always shadowed by their parents. // For instance, when mappings Laravel\Docs, we don't want the // main Laravel namespace to always override it. static::$namespaces = array_merge($namespaces, static::$namespaces); } /** * Format an array of directories with the proper trailing slashes. * * @param array $directories * @return array */ protected static function format($directories) { return array_map(function($directory) { return rtrim($directory, DS).DS; }, (array) $directories); } }