FeatureInstaller::installFeatures()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 4

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 7
cts 7
cp 1
rs 9.8666
c 0
b 0
f 0
cc 4
nc 4
nop 2
crap 4
1
<?php
2
3
namespace PSB\Core\Feature;
4
5
use PSB\Core\KnownSettingsEnum;
6
use PSB\Core\ObjectBuilder\BuilderInterface;
7
use PSB\Core\Util\Settings;
8
9
class FeatureInstaller
10
{
11
    /**
12
     * @var Feature[]
13
     */
14
    private $features;
15
16
    /**
17
     * @param Feature[] $features
18
     */
19 3
    public function __construct(array $features)
20
    {
21 3
        $this->features = $features;
22 3
    }
23
24
    /**
25
     * @param BuilderInterface $builder
26
     * @param Settings         $settings
27
     */
28 2
    public function installFeatures(BuilderInterface $builder, Settings $settings)
29
    {
30 2
        if (!$settings->tryGet(KnownSettingsEnum::INSTALLERS_ENABLED)) {
31 1
            return;
32
        }
33
34 1
        foreach ($this->features as $feature) {
35 1
            if ($feature->isActive()) {
36 1
                $feature->install($builder);
37
            }
38
        }
39 1
    }
40
}
41