Test Failed
Push — master ( 2c2c87...ed1c51 )
by Chris
25:05 queued 37s
created

SettingsSectionCollection::all()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Leonidas\Library\Admin\Page\SettingsSection;
4
5
use Leonidas\Contracts\Admin\Components\SettingsSectionCollectionInterface;
6
use Leonidas\Contracts\Admin\Components\SettingsSectionInterface;
7
8
class SettingsSectionCollection implements SettingsSectionCollectionInterface
9
{
10
    /**
11
     * @var SettingsSectionInterface[]
12
     */
13
    protected array $sections;
14
15
    public function __construct(SettingsSectionCollectionInterface ...$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