Manager   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 7
eloc 9
dl 0
loc 40
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getElement() 0 3 1
A removeElement() 0 3 1
A hasElement() 0 3 1
A accept() 0 3 1
A addElement() 0 3 1
A getElements() 0 3 1
A __construct() 0 3 1
1
<?php
2
3
/**
4
 * (c) FSi sp. z o.o. <[email protected]>
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
declare(strict_types=1);
11
12
namespace FSi\Bundle\AdminBundle\Admin;
13
14
use FSi\Bundle\AdminBundle\Admin\Manager\Visitor;
15
16
class Manager implements ManagerInterface
17
{
18
    /**
19
     * @var Element[]
20
     */
21
    protected $elements;
22
23
    public function __construct()
24
    {
25
        $this->elements = [];
26
    }
27
28
    public function addElement(Element $element): void
29
    {
30
        $this->elements[$element->getId()] = $element;
31
    }
32
33
    public function hasElement(string $id): bool
34
    {
35
        return array_key_exists($id, $this->elements);
36
    }
37
38
    public function getElement(string $id): Element
39
    {
40
        return $this->elements[$id];
41
    }
42
43
    public function removeElement(string $id): void
44
    {
45
        unset($this->elements[$id]);
46
    }
47
48
    public function getElements(): array
49
    {
50
        return $this->elements;
51
    }
52
53
    public function accept(Visitor $visitor): void
54
    {
55
        $visitor->visitManager($this);
56
    }
57
}
58