ListArgumentResolver::doResolve()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 1
dl 0
loc 8
ccs 5
cts 5
cp 1
crap 2
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