Passed
Pull Request — master (#74)
by Rustam
02:49
created

ServiceCollector   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
c 1
b 0
f 0
dl 0
loc 42
ccs 18
cts 18
cp 1
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getCollected() 0 3 1
A reset() 0 3 1
A collect() 0 25 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Yii\Debug\Collector;
6
7
final class ServiceCollector implements ServiceCollectorInterface
8
{
9
    use CollectorTrait;
10
11
    private array $items = [];
12
13 1
    public function getCollected(): array
14
    {
15 1
        return $this->items;
16
    }
17
18 4
    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 4
        if (!$this->isActive()) {
30 3
            return;
31
        }
32
33 1
        $this->items[] = [
34 1
            'service' => $service,
35 1
            'class' => $class,
36 1
            'method' => $method,
37 1
            'arguments' => $arguments,
38 1
            'result' => $result,
39 1
            'status' => $status,
40 1
            'error' => $error,
41 1
            'timeStart' => $timeStart,
42 1
            'timeEnd' => $timeEnd,
43
        ];
44 1
    }
45
46 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...
47
    {
48 1
        $this->items = [];
49 1
    }
50
}
51