Project   A
last analyzed

Complexity

Total Complexity 21

Size/Duplication

Total Lines 251
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 96.67%

Importance

Changes 0
Metric Value
wmc 21
lcom 1
cbo 2
dl 0
loc 251
ccs 58
cts 60
cp 0.9667
rs 10
c 0
b 0
f 0

21 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getName() 0 4 1
A setName() 0 4 1
A getBootstrap() 0 4 1
A setBootstrap() 0 4 1
A getDirectoryPath() 0 4 1
A setDirectoryPath() 0 4 1
A getPackage() 0 4 1
A getDescription() 0 4 1
A setDescription() 0 4 1
A getAuthors() 0 4 1
A setAuthors() 0 4 1
A addAuthor() 0 4 1
A getKeywords() 0 4 1
A setKeywords() 0 4 1
A getHomepage() 0 4 1
A setHomepage() 0 4 1
A getPackages() 0 4 1
A setPackages() 0 4 1
A addPackage() 0 4 1
A toConfig() 0 11 1
1
<?php
2
namespace Samurai\Project;
3
4
use Samurai\Alias\Alias;
5
6
/**
7
 * Class Project
8
 * @package Samurai
9
 * @author Raphaël Lefebvre <[email protected]>
10
 */
11
class Project 
12
{
13
    /**
14
     * @var string
15
     */
16
    private $name;
17
18
    /**
19
     * @var Alias
20
     */
21
    private $bootstrap;
22
23
    /**
24
     * @var string
25
     */
26
    private $directoryPath;
27
28
    /**
29
     * @var string
30
     */
31
    private $description;
32
33
    /**
34
     * @var Authors
35
     */
36
    private $authors;
37
38
    /**
39
     * @var array
40
     */
41
    private $keywords;
42
43
    /**
44
     * @var string
45
     */
46
    private $homepage;
47
48
    /**
49
     * @var Packages
50
     */
51
    private $packages;
52
53
    /**
54
     *
55
     */
56 42
    public function __construct()
57
    {
58 42
        $this->setAuthors(new Authors());
59 42
        $this->setPackages(new Packages());
60 42
    }
61
62
    /**
63
     * Getter of $name
64
     *
65
     * @return string
66
     */
67 12
    public function getName()
68
    {
69 12
        return $this->name;
70
    }
71
72
    /**
73
     * Setter of $name
74
     *
75
     * @param string $name
76
     */
77 8
    public function setName($name)
78
    {
79 8
        $this->name = (string)$name;
80 8
    }
81
82
    /**
83
     * Getter of $bootstrap
84
     *
85
     * @return Alias
86
     */
87 15
    public function getBootstrap()
88
    {
89 15
        return $this->bootstrap;
90
    }
91
92
    /**
93
     * Setter of $bootstrap
94
     *
95
     * @param Alias $bootstrap
96
     */
97 13
    public function setBootstrap(Alias $bootstrap)
98
    {
99 13
        $this->bootstrap = $bootstrap;
100 13
    }
101
102
    /**
103
     * Getter of $directoryPath
104
     *
105
     * @return string
106
     */
107 22
    public function getDirectoryPath()
108
    {
109 22
        return $this->directoryPath;
110
    }
111
112
    /**
113
     * Setter of $directoryPath
114
     * must be an absolute path.
115
     *
116
     * @param string $directoryPath
117
     */
118 13
    public function setDirectoryPath($directoryPath)
119
    {
120 13
        $this->directoryPath = (string)$directoryPath;
121 13
    }
122
123
    /**
124
     * @return mixed
125
     */
126
    public function getPackage()
127
    {
128
        return explode('/', $this->getName())[1];
129
    }
130
131
    /**
132
     * Getter of $description
133
     *
134
     * @return string
135
     */
136 7
    public function getDescription()
137
    {
138 7
        return $this->description;
139
    }
140
141
    /**
142
     * Setter of $description
143
     *
144
     * @param string $description
145
     */
146 5
    public function setDescription($description)
147
    {
148 5
        $this->description = (string)$description;
149 5
    }
150
151
    /**
152
     * Getter of $authors
153
     *
154
     * @return Authors
155
     */
156 8
    public function getAuthors()
157
    {
158 8
        return $this->authors;
159
    }
160
161
    /**
162
     * Setter of $authors
163
     *
164
     * @param Authors $authors
165
     */
166 42
    public function setAuthors(Authors $authors)
167
    {
168 42
        $this->authors = $authors;
169 42
    }
170
171
    /**
172
     * @param Author $author
173
     */
174 6
    public function addAuthor(Author $author)
175
    {
176 6
        $this->authors[] = $author;
177 6
    }
178
179
    /**
180
     * Getter of $keywords
181
     *
182
     * @return array
183
     */
184 7
    public function getKeywords()
185
    {
186 7
        return $this->keywords;
187
    }
188
189
    /**
190
     * Setter of $keywords
191
     *
192
     * @param array $keywords
193
     */
194 5
    public function setKeywords(array $keywords)
195
    {
196 5
        $this->keywords = $keywords;
197 5
    }
198
199
    /**
200
     * Getter of $homepage
201
     *
202
     * @return string
203
     */
204 8
    public function getHomepage()
205
    {
206 8
        return $this->homepage;
207
    }
208
209
    /**
210
     * Setter of $homepage
211
     *
212
     * @param string $homepage
213
     */
214 6
    public function setHomepage($homepage)
215
    {
216 6
        $this->homepage = (string)$homepage;
217 6
    }
218
219
    /**
220
     * Getter of $package
221
     *
222
     * @return Packages
223
     */
224 5
    public function getPackages()
225
    {
226 5
        return $this->packages;
227
    }
228
229
    /**
230
     * Setter of $packages
231
     *
232
     * @param Packages $packages
233
     */
234 42
    public function setPackages(Packages $packages)
235
    {
236 42
        $this->packages = $packages;
237 42
    }
238
239
    /**
240
     * @param Package $package
241
     */
242 2
    public function addPackage(Package $package)
243
    {
244 2
        $this->packages[] = $package;
245 2
    }
246
247
    /**
248
     * @return array
249
     */
250 5
    public function toConfig()
251
    {
252
        return [
253 5
            'name' => $this->getName(),
254 5
            'description' => $this->getDescription(),
255 5
            'keywords' => $this->getKeywords(),
256 5
            'homepage' => $this->getHomepage(),
257 5
            'authors' => $this->getAuthors()->toArray(),
258 5
            'autoload' => $this->getPackages()->toArray(),
259 5
        ];
260
    }
261
}
262