Feature::jsonSerialize()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 6
ccs 0
cts 4
cp 0
crap 2
rs 10
c 1
b 0
f 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Pheature\Model\Toggle;
6
7
use Pheature\Core\Toggle\Read\Feature as IFeature;
8
use Pheature\Core\Toggle\Read\ToggleStrategies;
9
10
final class Feature implements IFeature
11
{
12
    private string $id;
13
    private ToggleStrategies $strategies;
14
    private bool $enabled;
15
16 2
    public function __construct(
17
        string $id,
18
        ToggleStrategies $strategies,
19
        bool $enabled
20
    ) {
21 2
        $this->id = $id;
22 2
        $this->strategies = $strategies;
23 2
        $this->enabled = $enabled;
24
    }
25
26 2
    public function id(): string
27
    {
28 2
        return $this->id;
29
    }
30
31 2
    public function strategies(): ToggleStrategies
32
    {
33 2
        return $this->strategies;
34
    }
35
36 2
    public function isEnabled(): bool
37
    {
38 2
        return $this->enabled;
39
    }
40
41
    public function jsonSerialize(): array
42
    {
43
        return [
44
            'id' => $this->id,
45
            'strategies' => $this->strategies->jsonSerialize(),
46
            'enabled' => $this->enabled,
47
        ];
48
    }
49
}
50