SettingsSectionCollection   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 35
ccs 0
cts 12
cp 0
rs 10
c 0
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A all() 0 3 1
A remove() 0 3 1
A get() 0 3 1
A has() 0 3 1
A add() 0 3 1
A __construct() 0 3 1
1
<?php
2
3
namespace Leonidas\Library\Admin\Component\SettingsSection;
4
5
use Leonidas\Contracts\Admin\Component\SettingsSection\SettingsSectionCollectionInterface;
6
use Leonidas\Contracts\Admin\Component\SettingsSection\SettingsSectionInterface;
7
8
class SettingsSectionCollection implements SettingsSectionCollectionInterface
9
{
10
    /**
11
     * @var SettingsSectionInterface[]
12
     */
13
    protected array $sections = [];
14
15
    public function __construct(SettingsSectionInterface ...$sections)
16
    {
17
        array_map([$this, 'add'], $sections);
18
    }
19
20
    public function add(SettingsSectionInterface $section)
21
    {
22
        $this->sections[$section->getId()] = $section;
23
    }
24
25
    public function get(string $section): SettingsSectionInterface
26
    {
27
        return $this->sections[$section];
28
    }
29
30
    public function remove(string $section)
31
    {
32
        unset($this->sections[$section]);
33
    }
34
35
    public function has(string $section): bool
36
    {
37
        return isset($this->sections[$section]);
38
    }
39
40
    public function all(): array
41
    {
42
        return $this->sections;
43
    }
44
}
45