ListArgumentResolver::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace Diezz\YamlToObjectMapper\Resolver;
4
5
class ListArgumentResolver extends SystemArgumentResolver
6
{
7
    /**
8
     * @var ArgumentResolver[]
9
     */
10
    private array $elements;
11
12
    /**
13
     * @param ArgumentResolver[] $elements
14
     */
15 4
    public function __construct(array $elements)
16
    {
17 4
        $this->elements = $elements;
18 4
    }
19
20 4
    protected function doResolve($context = null): array
21
    {
22 4
        $result = [];
23 4
        foreach ($this->elements as $key => $item) {
24 4
            $result[$key] = $item->resolve($context);
25
        }
26
27 4
        return $result;
28
    }
29
30
    public function findByPath(string $path): ?ArgumentResolver
31
    {
32
        return $this->elements[$path] ?? null;
33
    }
34
}
35