Passed
Push — master ( 82a58b...d35cf8 )
by Tomasz
02:32
created

BinaryUuidTransformerWalker::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
crap 1
1
<?php
2
declare(strict_types=1);
3
4
namespace ReadModel\Walker;
5
6
class BinaryUuidTransformerWalker implements ResultWalker
7
{
8
    /** @var BinaryUuidTransformer */
9
    private $transformer;
10
11
    /** @var array */
12
    private $keys;
13
14 3
    public function __construct(BinaryUuidTransformer $transformer, string ...$keys)
15
    {
16 3
        $this->transformer = $transformer;
17 3
        $this->keys = array_combine($keys, $keys);
18 3
    }
19
20
    public function walk(array $result): array
21
    {
22 1
        array_walk($result, function (&$value, $key) {
23 1
            if ($value === null || !isset($this->keys[$key])) {
24 1
                return;
25
            }
26
27 1
            $value = $this->transformer->transformToString($value);
28 1
        });
29
30
        return $result;
31
    }
32
}
33