Passed
Push — master ( e641c2...af3801 )
by Pierre
12:25
created

DictionaryDataCollector   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Test Coverage

Coverage 85.71%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 8
c 2
b 0
f 0
dl 0
loc 36
ccs 12
cts 14
cp 0.8571
rs 10
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 3 1
A collect() 0 2 1
A addDictionary() 0 6 1
A reset() 0 2 1
A getDictionaries() 0 4 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Knp\DictionaryBundle\DataCollector;
6
7
use Generator;
8
use Symfony\Component\HttpFoundation\Request;
9
use Symfony\Component\HttpFoundation\Response;
10
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
11
use Throwable;
12 1
13
final class DictionaryDataCollector extends DataCollector
14
{
15
    public function collect(Request $request, Response $response, Throwable $exception = null): void
16
    {
17
    }
18 9
19
    /**
20 9
     * @param array<mixed> $keys
21 9
     * @param array<mixed> $values
22 9
     */
23 9
    public function addDictionary(string $name, array $keys, array $values): void
24
    {
25
        $this->data[$name] = array_map(
26
            fn ($key, $value): array => ['key' => $key, 'value' => $value],
27 9
            $keys,
28
            $values
29
        );
30
    }
31
32 9
    /**
33
     * @return Generator<string, array<mixed>>
34 9
     */
35 8
    public function getDictionaries(): Generator
36
    {
37 9
        foreach ($this->data as $name => $keyValuePairs) {
38
            yield $name => $keyValuePairs;
39
        }
40
    }
41
42
    public function reset(): void
43 1
    {
44
    }
45 1
46
    public function getName(): string
47
    {
48
        return 'dictionary';
49
    }
50
}
51