Completed
Pull Request — master (#202)
by personal
03:41 queued 42s
created

Repository   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
c 1
b 0
f 1
lcom 1
cbo 1
dl 0
loc 42
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A attach() 0 4 1
A detach() 0 4 1
A has() 0 4 1
A all() 0 4 1
1
<?php
2
3
/*
4
 * (c) Jean-François Lépine <https://twitter.com/Halleck45>
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace Hal\Application\Extension;
11
12
class Repository{
13
14
    /**
15
     * @var array
16
     */
17
    private $extensions = array();
18
19
    /**
20
     * @param Extension $extension
21
     * @return $this
22
     */
23
    public function attach(Extension $extension) {
24
        $this->extensions[$extension->getName()] = $extension;
25
        return $this;
26
    }
27
28
    /**
29
     * @param Extension $extension
30
     * @return $this
31
     */
32
    public function detach(Extension $extension) {
33
        unset($this->extensions[$extension->getName()]);
34
        return $this;
35
    }
36
37
    /**
38
     * @param Extension $extension
39
     * @return bool
40
     */
41
    public function has(Extension $extension)
42
    {
43
        return isset($this->extensions[$extension->getName()]);
44
    }
45
46
    /**
47
     * @return Extension[]
48
     */
49
    public function all()
50
    {
51
        return $this->extensions;
52
    }
53
}