Passed
Push — master ( f7ef7a...65c26d )
by Dmitriy
02:46
created

ServiceCollector   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 20
dl 0
loc 51
ccs 10
cts 10
cp 1
rs 10
c 1
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getCollected() 0 3 1
A collect() 0 25 2
A reset() 0 3 1
A getSummary() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Yii\Debug\Collector;
6
7
final class ServiceCollector implements SummaryCollectorInterface
8
{
9
    use CollectorTrait;
10
11
    private array $items = [];
12
13 2
    public function getCollected(): array
14
    {
15 2
        return $this->items;
16
    }
17
18 7
    public function collect(
19
        string $service,
20
        string $class,
21
        string $method,
22
        ?array $arguments,
23
        $result,
24
        string $status,
25
        ?object $error,
26
        float $timeStart,
27
        float $timeEnd
28
    ): void {
29 7
        if (!$this->isActive()) {
30 5
            return;
31
        }
32
33 2
        $this->items[] = [
34
            'service' => $service,
35
            'class' => $class,
36
            'method' => $method,
37
            'arguments' => $arguments,
38
            'result' => $result,
39
            'status' => $status,
40
            'error' => $error,
41
            'timeStart' => $timeStart,
42
            'timeEnd' => $timeEnd,
43
        ];
44
    }
45
46 1
    public function getSummary(): array
47
    {
48
        return [
49
            'service' => [
50 1
                'total' => count($this->items),
51
            ],
52
        ];
53
    }
54
55 1
    private function reset(): void
0 ignored issues
show
Unused Code introduced by
The method reset() is not used, and could be removed.

This check looks for private methods that have been defined, but are not used inside the class.

Loading history...
56
    {
57 1
        $this->items = [];
58
    }
59
}
60