DictionaryDataCollector   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 84.62%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 8
c 2
b 0
f 0
dl 0
loc 32
ccs 11
cts 13
cp 0.8462
rs 10
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 3 1
A collect() 0 1 1
A addDictionary() 0 6 1
A reset() 0 1 1
A getDictionaries() 0 4 2
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