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

ServiceCollector::getIndexData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
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