Code Duplication    Length = 19-19 lines in 2 locations

src/ClassNameMapper.php 2 locations

@@ 29-47 (lines=19) @@
26
     * @param string $namespace The namespace to register
27
     * @param string|array $path The path on the filesystem (or an array of paths)
28
     */
29
    public function registerPsr0Namespace($namespace, $path) {
30
        // A namespace always ends with a \
31
        $namespace = trim($namespace, '\\').'\\';
32
        if ($namespace === '\\') {
33
            $namespace = '';
34
        }
35
36
        if (!is_array($path)) {
37
            $path = [$path];
38
        }
39
        // Paths always end with a /
40
        $paths = array_map([self::class, 'normalizeDirectory'], $path);
41
42
        if (!isset($this->psr0Namespaces[$namespace])) {
43
            $this->psr0Namespaces[$namespace] = $paths;
44
        } else {
45
            $this->psr0Namespaces[$namespace] = array_merge($this->psr0Namespaces[$namespace], $paths);
46
        }
47
    }
48
49
    /**
50
     * Registers a PSR-4 namespace.
@@ 55-73 (lines=19) @@
52
     * @param string $namespace The namespace to register
53
     * @param string|array $path The path on the filesystem (or an array of paths)
54
     */
55
    public function registerPsr4Namespace($namespace, $path) {
56
        // A namespace always ends with a \
57
        $namespace = trim($namespace, '\\').'\\';
58
        if ($namespace === '\\') {
59
            $namespace = '';
60
        }
61
62
        if (!is_array($path)) {
63
            $path = [$path];
64
        }
65
        // Paths always end with a /
66
        $paths = array_map([self::class, 'normalizeDirectory'], $path);
67
68
        if (!isset($this->psr4Namespaces[$namespace])) {
69
            $this->psr4Namespaces[$namespace] = $paths;
70
        } else {
71
            $this->psr4Namespaces[$namespace] = array_merge($this->psr4Namespaces[$namespace], $paths);
72
        }
73
    }
74
75
    /**
76
     * @param string $composerJsonPath