SectionCollection::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 2
nop 1
crap 2
1
<?php
2
3
namespace MyOnlineStore\Bundle\RabbitMqManagerBundle\Configuration\Section;
4
5
use Supervisor\Configuration\Section;
6
7
final class SectionCollection
8
{
9
    /**
10
     * @var Section[]
11
     */
12
    private $sections = [];
13
14
    /**
15
     * @param Section[] $sections
16
     */
17 9
    public function __construct(array $sections = [])
18
    {
19 9
        foreach ($sections as $section) {
20 1
            $this->addSection($section);
21 9
        }
22 9
    }
23
24
    /**
25
     * @param Section $section
26
     */
27 8
    public function addSection(Section $section)
28
    {
29 8
        $this->sections[$section->getName()] = $section->getProperties();
30 8
    }
31
32
    /**
33
     * @return array
34
     */
35 5
    public function toArray()
36
    {
37 5
        return $this->sections;
38
    }
39
}
40