Final Class Yiisoft\Yii\Debug\Collector\HttpClientCollector
| Inheritance | Yiisoft\ |
|---|---|
| Implements | Yiisoft\ |
| Uses Traits | Yiisoft\ |
Public Methods
Method Details
| public mixed __construct ( Yiisoft\ | ||
| $timelineCollector | Yiisoft\ |
|
public function __construct(
private readonly TimelineCollector $timelineCollector,
) {}
| public void collect ( \ | ||
| $request | \ |
|
| $startTime | float | |
| $line | string | |
| $uniqueId | string | |
public function collect(RequestInterface $request, float $startTime, string $line, string $uniqueId): void
{
if (!$this->isActive()) {
return;
}
$this->requests[$uniqueId][] = [
'startTime' => $startTime,
'endTime' => $startTime,
'totalTime' => 0.0,
'method' => $request->getMethod(),
'uri' => (string) $request->getUri(),
'headers' => $request->getHeaders(),
'line' => $line,
];
$this->timelineCollector->collect($this, $uniqueId);
}
| public void collectTotalTime ( ?\ | ||
| $response | ?\ |
|
| $endTime | float | |
| $uniqueId | ?string | |
public function collectTotalTime(?ResponseInterface $response, float $endTime, ?string $uniqueId): void
{
if (!$this->isActive()) {
return;
}
if (!isset($this->requests[$uniqueId])) {
return;
}
/** @psalm-suppress UnsupportedReferenceUsage */
$entry = &$this->requests[$uniqueId][count($this->requests[$uniqueId]) - 1];
if ($response instanceof ResponseInterface) {
$entry['responseRaw'] = Message::toString($response);
$entry['responseStatus'] = $response->getStatusCode();
Message::rewindBody($response);
}
$entry['endTime'] = $endTime;
$entry['totalTime'] = $entry['endTime'] - $entry['startTime'];
}
| public array getCollected ( ) |
public function getCollected(): array
{
if (!$this->isActive()) {
return [];
}
return array_merge(...array_values($this->requests));
}
| public array getSummary ( ) |
public function getSummary(): array
{
if (!$this->isActive()) {
return [];
}
return [
'count' => array_sum(array_map(count(...), $this->requests)),
'totalTime' => array_sum(
array_merge(
...array_map(
static fn(array $entry) => array_column($entry, 'totalTime'),
array_values($this->requests),
),
),
),
];
}
| public void shutdown ( ) |
public function shutdown(): void
{
$this->reset();
$this->isActive = false;
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.