Passed
Push — 1.0.x ( e5e1d1...c19ecc )
by Koldo
11:20
created

ToggleConfig::prefix()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Pheature\Crud\Psr11\Toggle;
6
7
use Webmozart\Assert\Assert;
8
9
final class ToggleConfig
10
{
11
    private string $driver;
12
    private string $apiPrefix;
13
    /** @var array<string, mixed> */
14
    private array $toggles = [];
15
16
    /**
17
     * @param array<string, mixed> $config
18
     */
19 10
    public function __construct(array $config)
20
    {
21 10
        Assert::keyExists($config, 'api_prefix');
22 10
        Assert::keyExists($config, 'driver');
23 10
        Assert::string($config['api_prefix']);
24 10
        Assert::string($config['driver']);
25 10
        $this->apiPrefix = $config['api_prefix'];
26 10
        $this->driver = $config['driver'];
27 10
        if (array_key_exists('toggles', $config)) {
28
            Assert::isArray($config['toggles']);
29
            /** @var array<string, mixed> $toggles */
30
            $toggles = $config['toggles'];
31
            $this->toggles = $toggles;
32
        }
33 10
    }
34
35
    public function apiPrefix(): string
36
    {
37
        return $this->apiPrefix;
38
    }
39
40 10
    public function driver(): string
41
    {
42 10
        return $this->driver;
43
    }
44
45
    /**
46
     * @return array<string, mixed>
47
     */
48 2
    public function toggles(): array
49
    {
50 2
        return $this->toggles;
51
    }
52
}
53