Passed
Push — 1.0.x ( 48f1ab...7d1554 )
by Koldo
30:19 queued 27:51
created

ToggleConfigFactory   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 16
ccs 7
cts 7
cp 1
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 12 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Pheature\Crud\Psr11\Toggle;
6
7
use Psr\Container\ContainerInterface;
8
use Webmozart\Assert\Assert;
9
10
final class ToggleConfigFactory
11
{
12
    private const MISSING_CONFIG = '"pheature_flags" configuration not found in container';
13
14 3
    public function __invoke(ContainerInterface $container): ToggleConfig
15
    {
16
        /** @var array<string, mixed>|mixed $config */
17 3
        $config = $container->get('config');
18 3
        Assert::isArray($config);
19 3
        Assert::keyExists($config, 'pheature_flags', self::MISSING_CONFIG);
20 2
        Assert::isArray($config['pheature_flags'], self::MISSING_CONFIG);
21
22
        /** @var array<string, mixed> $pheatureConfig */
23 2
        $pheatureConfig = $config['pheature_flags'];
24
25 2
        return new ToggleConfig($pheatureConfig);
26
    }
27
}
28