Composer   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 9
lcom 1
cbo 1
dl 0
loc 43
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getComposerPath() 0 3 1
A getCanonicalClassMap() 0 3 1
A getClassMap() 0 4 1
A canonicalizeClassMap() 0 7 2
A getVendorLibs() 0 16 3
1
<?php
2
3
namespace Padawan\Framework\Utils;
4
5
class Composer {
6
    private $vendorPath;
7
    private $loader;
0 ignored issues
show
Unused Code introduced by
The property $loader is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
8
    private $path;
9
10
    public function __construct(PathResolver $path, $vendorPath = 'vendor') {
11
        $this->vendorPath = $vendorPath;
12
        $this->path = $path;
13
    }
14
    public function getComposerPath() {
15
        return $this->path->join([$this->vendorPath, 'composer']);
16
    }
17
    public function getCanonicalClassMap($cwd) {
18
        return $this->canonicalizeClassMap($cwd, $this->getClassMap());
19
    }
20
    public function getClassMap() {
21
        return require $this->path
22
            ->join([$this->getComposerPath(), 'autoload_classmap.php']);
23
    }
24
    public function canonicalizeClassMap($cwd, $classMap) {
25
        foreach ($classMap as $key => $item) {
26
            $item = $this->path->canonical($item);
27
            $classMap[$key] = str_replace($cwd, '', $item);
28
        }
29
        return $classMap;
30
    }
31
    public function getVendorLibs($rootDir)
32
    {
33
        $vendorLibs = array();
34
        $autoloadNamespaces = require $this->path->join([
35
            $rootDir,
36
            $this->getComposerPath(),
37
            'autoload_namespaces.php'
38
        ]);
39
        foreach ($autoloadNamespaces as $namespace => $directory) {
40
            if ($namespace == "") {
41
                continue;
42
            }
43
            $vendorLibs[$namespace] = $this->path->canonical($directory[0]);
44
        }
45
        return $vendorLibs;
46
    }
47
}
48