Total Complexity | 6 |
Total Lines | 31 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
13 | final class Value implements Factory |
||
14 | { |
||
15 | public function __construct(private readonly ValueTransformer $valueTransformer) {} |
||
16 | |||
17 | /** |
||
18 | * {@inheritdoc} |
||
19 | * |
||
20 | 5 | * @throw InvalidArgumentException Not able to create a dictionary with the given name |
|
21 | */ |
||
22 | 5 | public function create(string $name, array $config): Dictionary |
|
23 | 5 | { |
|
24 | if (!isset($config['content'])) { |
||
25 | throw new \InvalidArgumentException(\sprintf( |
||
26 | 'The key content for dictionary %s must be set.', |
||
27 | $name |
||
28 | )); |
||
29 | } |
||
30 | 2 | ||
31 | $content = $config['content']; |
||
32 | 2 | $values = []; |
|
33 | 1 | ||
34 | 1 | foreach ($content as $value) { |
|
35 | $values[] = $this->valueTransformer->transform($value); |
||
36 | } |
||
37 | |||
38 | return new Simple($name, $values); |
||
39 | 1 | } |
|
40 | 1 | ||
41 | public function supports(array $config): bool |
||
44 | } |
||
45 | } |
||
46 |