SettingsSectionCollection::all()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
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