Root   A
last analyzed

Complexity

Total Complexity 13

Size/Duplication

Total Lines 105
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 13
lcom 2
cbo 1
dl 0
loc 105
ccs 0
cts 44
cp 0
rs 10
c 0
b 0
f 0

9 Methods

Rating   Name   Duplication   Size   Complexity  
A setBasePath() 0 4 1
A addFile() 0 4 1
A addDirectory() 0 4 1
A getBasePath() 0 4 1
A getFileCollection() 0 4 1
A getDirectoryCollection() 0 4 1
A hasDirectory() 0 4 1
A getDirectoryByName() 0 4 1
A getAllDirIn() 0 17 5
1
<?php
2
3
/**
4
 * This file is part of the Clover to Html package.
5
 *
6
 * (c) Stéphane Demonchaux <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
namespace CloverToHtml;
12
13
class Root
14
{
15
    /**
16
     * @var array
17
     */
18
    private $directories = array();
19
    /**
20
     * @var array
21
     */
22
    private $files = array();
23
    /**
24
     * @var string
25
     */
26
    private $basePath;
27
28
    /**
29
     * @param string $basePath
30
     */
31
    public function setBasePath($basePath): void
32
    {
33
        $this->basePath = $basePath;
34
    }
35
36
    /**
37
     * @param File $file
38
     */
39
    public function addFile(File $file): void
40
    {
41
        $this->files[] = $file;
42
    }
43
44
    /**
45
     * @param Directory $directory
46
     */
47
    public function addDirectory(Directory $directory): void
48
    {
49
        $this->directories[$directory->getPath()] = $directory;
50
    }
51
52
    /**
53
     * @return string
54
     */
55
    public function getBasePath(): string
56
    {
57
        return $this->basePath;
58
    }
59
60
    /**
61
     * @return File[]
62
     */
63
    public function getFileCollection(): array
64
    {
65
        return $this->files;
66
    }
67
68
    /**
69
     * @return array
70
     */
71
    public function getDirectoryCollection(): array
72
    {
73
        return $this->directories;
74
    }
75
76
    /**
77
     * @param string $name
78
     *
79
     * @return bool
80
     */
81
    public function hasDirectory($name): bool
82
    {
83
        return isset($this->directories[$name]);
84
    }
85
86
    /**
87
     * @param string $name
88
     *
89
     * @return Directory
90
     */
91
    public function getDirectoryByName($name): Directory
92
    {
93
        return $this->directories[$name];
94
    }
95
96
    /**
97
     * @param Directory $directory
98
     * @return Directory[]
99
     */
100
    public function getAllDirIn(Directory $directory): array
101
    {
102
        $dirCollection  = array();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 1 space but found 2 spaces

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
103
        $currentDir     = trim($directory->getPath());
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 4 spaces but found 5 spaces

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
104
105
        foreach ($this->directories as $path => $dir) {
106
            /* @var $dir Directory */
107
            if ($currentDir !== '' &&
108
                trim($path) !== $currentDir &&
109
                strpos(trim($path), $currentDir) === 0
110
                ) {
111
                $dirCollection[] = $dir;
112
            }
113
        }
114
115
        return $dirCollection;
116
    }
117
}
118