Passed
Pull Request — master (#114)
by Alexander
03:04 queued 17s
created

ServiceCollector   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A collect() 0 25 2
A getCollected() 0 3 1
A reset() 0 3 1
A getIndexData() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Yii\Debug\Collector;
6
7
use JetBrains\PhpStorm\ArrayShape;
8
9
final class ServiceCollector implements ServiceCollectorInterface, IndexCollectorInterface
10
{
11
    use CollectorTrait;
12
13
    private array $items = [];
14
15 2
    public function getCollected(): array
16
    {
17 2
        return $this->items;
18
    }
19
20 7
    public function collect(
21
        string $service,
22
        string $class,
23
        string $method,
24
        ?array $arguments,
25
        $result,
26
        string $status,
27
        ?object $error,
28
        float $timeStart,
29
        float $timeEnd
30
    ): void {
31 7
        if (!$this->isActive()) {
32 5
            return;
33
        }
34
35 2
        $this->items[] = [
36 2
            'service' => $service,
37 2
            'class' => $class,
38 2
            'method' => $method,
39 2
            'arguments' => $arguments,
40 2
            'result' => $result,
41 2
            'status' => $status,
42 2
            'error' => $error,
43 2
            'timeStart' => $timeStart,
44 2
            'timeEnd' => $timeEnd,
45
        ];
46 2
    }
47
48 1
    #[ArrayShape(['totalServices' => 'int'])]
49
    public function getIndexData(): array
50
    {
51
        return [
52 1
            'totalServices' => count($this->items),
53
        ];
54
    }
55
56 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...
57
    {
58 1
        $this->items = [];
59 1
    }
60
}
61