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

DictionaryDataCollector::collect()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 0
c 1
b 0
f 0
nc 1
nop 3
dl 0
loc 2
ccs 0
cts 0
cp 0
crap 2
rs 10
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