Commit 77502066 authored by Taylor Otwell's avatar Taylor Otwell

automatically prepare the directories registered with the auto-loader.

parent 490fd46c
...@@ -160,11 +160,7 @@ class Autoloader { ...@@ -160,11 +160,7 @@ class Autoloader {
*/ */
public static function psr($directory) public static function psr($directory)
{ {
$directories = array_map(function($directory) $directories = static::format($directory);
{
return rtrim($directory, '/').'/';
}, (array) $directory);
static::$psr = array_unique(array_merge(static::$psr, $directories)); static::$psr = array_unique(array_merge(static::$psr, $directories));
} }
...@@ -177,7 +173,26 @@ class Autoloader { ...@@ -177,7 +173,26 @@ class Autoloader {
*/ */
public static function namespaces($mappings) public static function namespaces($mappings)
{ {
$directories = static::format(array_values($mappings));
$mappings = array_combine(array_keys($mappings), $directories);
static::$namespaces = array_merge(static::$namespaces, $mappings); static::$namespaces = array_merge(static::$namespaces, $mappings);
} }
/**
* 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);
}
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment