-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathServiceCollector.php
70 lines (60 loc) · 1.46 KB
/
ServiceCollector.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
declare(strict_types=1);
namespace Yiisoft\Yii\Debug\Collector;
final class ServiceCollector implements SummaryCollectorInterface
{
use CollectorTrait;
private array $items = [];
public function __construct(private TimelineCollector $timelineCollector)
{
}
public function getCollected(): array
{
if (!$this->isActive()) {
return [];
}
return $this->items;
}
public function collect(
string $service,
string $class,
string $method,
?array $arguments,
$result,
string $status,
?object $error,
float $timeStart,
float $timeEnd
): void {
if (!$this->isActive()) {
return;
}
$this->items[] = [
'service' => $service,
'class' => $class,
'method' => $method,
'arguments' => $arguments,
'result' => $result,
'status' => $status,
'error' => $error,
'timeStart' => $timeStart,
'timeEnd' => $timeEnd,
];
$this->timelineCollector->collect($this, count($this->items));
}
public function getSummary(): array
{
if (!$this->isActive()) {
return [];
}
return [
'service' => [
'total' => count($this->items),
],
];
}
private function reset(): void
{
$this->items = [];
}
}