Completed
Pull Request — 0.3 (#18)
by jean
02:44
created

ConfigurationStep::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 4
dl 0
loc 6
ccs 5
cts 5
cp 1
crap 1
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: darkilliant
5
 * Date: 5/8/18
6
 * Time: 11:04 AM.
7
 */
8
9
namespace Darkilliant\ProcessBundle\Configuration;
10
11
class ConfigurationStep
12
{
13
    private $next;
0 ignored issues
show
introduced by
The private property $next is not used, and could be removed.
Loading history...
14
15
    private $options;
16
17
    private $service;
18
19
    /** @var bool */
20
    private $enabled;
21
22 9
    private function __construct(string $service, array $options, array $children, bool $enabled = true)
23
    {
24 9
        $this->service = $service;
25 9
        $this->options = $options;
26 9
        $this->children = array_map([ConfigurationStep::class, 'create'], $children);
0 ignored issues
show
Bug Best Practice introduced by
The property children does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
27 9
        $this->enabled = $enabled;
28 9
    }
29
30 9
    public static function create(array $config)
31
    {
32 9
        return new self($config['service'], $config['options'] ?? [], $config['children'] ?? [], $config['enabled'] ?? true);
33
    }
34
35 7
    public function getOptions(): array
36
    {
37 7
        return $this->options;
38
    }
39
40 7
    public function getService(): string
41
    {
42 7
        return $this->service;
43
    }
44
45 4
    public function getChildren(): array
46
    {
47 4
        return $this->children;
48
    }
49
50 7
    public function isEnabled()
51
    {
52 7
        return $this->enabled;
53
    }
54
}
55