DictionaryDataCollector::getDictionaries()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 2
c 0
b 0
f 0
nc 2
nop 0
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Knp\DictionaryBundle\DataCollector;
6
7
use Symfony\Component\HttpFoundation\Request;
8
use Symfony\Component\HttpFoundation\Response;
9
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
10
11
final class DictionaryDataCollector extends DataCollector
12 1
{
13
    public function collect(Request $request, Response $response, ?\Throwable $throwable = null): void {}
14
15
    /**
16
     * @param array<mixed> $keys
17
     * @param array<mixed> $values
18 9
     */
19
    public function addDictionary(string $name, array $keys, array $values): void
20 9
    {
21 9
        $this->data[$name] = array_map(
22 9
            static fn ($key, $value): array => ['key' => $key, 'value' => $value],
23 9
            $keys,
24
            $values
25
        );
26
    }
27 9
28
    /**
29
     * @return \Generator<string, array<mixed>>
30
     */
31
    public function getDictionaries(): \Generator
32 9
    {
33
        foreach ($this->data as $name => $keyValuePairs) {
34 9
            yield $name => $keyValuePairs;
35 8
        }
36
    }
37 9
38
    public function reset(): void {}
39
40
    public function getName(): string
41
    {
42
        return 'dictionary';
43 1
    }
44
}
45