OSDN Git Service

refactor functions
authorfrostbane <frostbane@programmer.net>
Mon, 9 Dec 2019 07:01:52 +0000 (16:01 +0900)
committerfrostbane <frostbane@programmer.net>
Mon, 9 Dec 2019 07:01:52 +0000 (16:01 +0900)
move private functions to the top

src/autoloader/Psr0.php

index c80a41a..3804218 100644 (file)
@@ -129,6 +129,59 @@ class Psr0
 
     /**
      * @codeCoverageIgnore
+     *
+     * @param string[] $paths
+     *
+     * @return array
+     */
+    private function __filterTrimPaths(array &$paths)
+    {
+        return array_map(function ($p) {
+            return rtrim($p, "/\\") . DIRECTORY_SEPARATOR;
+        }, array_filter($paths, function ($p) {
+            return !empty($p) && is_string($p);
+        }));
+    }
+
+    /**
+     * normalize arguments
+     *
+     * either `$namespace` and $path` are both strings or
+     * `$namespace` is an array containing namespaces and path pairs
+     * and `$path` is null
+     *
+     * if the parameters are invalid an `\InvalidArgumentException`
+     * is thrown.
+     *
+     * @CodeCoverageIgnore
+     *
+     * @param $namespace
+     * @param $path
+     *
+     * @return array|string
+     *
+     * @throws \InvalidArgumentException
+     */
+    private function __getValidNamespacePaths($namespace, $path)
+    {
+        if (is_string($namespace) && is_string($path)) {
+            $namespace = array($namespace => $path);
+            $path      = null;
+        }
+
+        if ($path !== null || !is_array($namespace)) {
+            throw new \InvalidArgumentException("Invalid argument");
+        }
+
+        foreach ($namespace as $n => &$p) {
+            $p = str_replace("\\/", DIRECTORY_SEPARATOR, $p);
+        }
+
+        return $namespace;
+    }
+
+    /**
+     * @codeCoverageIgnore
      */
     private function __registerAutoloader()
     {
@@ -157,22 +210,6 @@ class Psr0
     }
 
     /**
-     * @codeCoverageIgnore
-     *
-     * @param string[] $paths
-     *
-     * @return array
-     */
-    private function __filterTrimPaths(array &$paths)
-    {
-        return array_map(function ($p) {
-            return rtrim($p, "/\\") . DIRECTORY_SEPARATOR;
-        }, array_filter($paths, function ($p) {
-            return !empty($p) && is_string($p);
-        }));
-    }
-
-    /**
      * add path to autoload path(s)
      *
      * @codeCoverageIgnore
@@ -235,43 +272,6 @@ class Psr0
     }
 
     /**
-     * normalize arguments
-     *
-     * either `$namespace` and $path` are both strings or
-     * `$namespace` is an array containing namespaces and path pairs
-     * and `$path` is null
-     *
-     * if the parameters are invalid an `\InvalidArgumentException`
-     * is thrown.
-     *
-     * @CodeCoverageIgnore
-     *
-     * @param $namespace
-     * @param $path
-     *
-     * @return array|string
-     *
-     * @throws \InvalidArgumentException
-     */
-    private function __getValidNamespacePaths($namespace, $path)
-    {
-        if (is_string($namespace) && is_string($path)) {
-            $namespace = array($namespace => $path);
-            $path      = null;
-        }
-
-        if ($path !== null || !is_array($namespace)) {
-            throw new \InvalidArgumentException("Invalid argument");
-        }
-
-        foreach ($namespace as $n => &$p) {
-            $p = str_replace("\\/", DIRECTORY_SEPARATOR, $p);
-        }
-
-        return $namespace;
-    }
-
-    /**
      * add path to autoload path(s) that is prefixed with a namespace
      *
      * @param string|array $namespace