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

BinaryUuidTransformerWalker   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
dl 0
loc 25
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A walk() 0 11 3
A __construct() 0 4 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