Skip to content

Commit c252717

Browse files
committed
update
1 parent a3bfa9f commit c252717

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

src/DebuggerTool.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
namespace MintyPHP\Tools;
44

55
use MintyPHP\Core\Debugger;
6+
use MintyPHP\Core\Debugger\ApiCall;
7+
use MintyPHP\Core\Debugger\ApiCallTiming;
68
use MintyPHP\Core\Debugger\Request;
79
use MintyPHP\Core\Debugger\Query;
810

@@ -546,6 +548,7 @@ public function getApiCallsTabPane(int $requestId, Request $request): string
546548
$count = 0;
547549
$total = 0;
548550
foreach ($request->apiCalls as $i => $call) {
551+
/** @var ApiCall $call */
549552
$count++;
550553
$total += $call->duration;
551554
$url = $call->url;
@@ -572,10 +575,16 @@ public function getApiCallsTabPane(int $requestId, Request $request): string
572575
$tables['details']['data_received'] = $call->body ? '<a href="data:application/json;charset=UTF-8;base64,' . base64_encode($call->body) . '">View (' . strlen($call->body) . ' bytes)</a>' : '-';
573576
$tables['details']['headers_sent'] = $call->headers ? '<a href="data:application/json;charset=UTF-8;base64,' . base64_encode(json_encode($call->headers, JSON_PRETTY_PRINT + JSON_UNESCAPED_SLASHES + JSON_UNESCAPED_UNICODE) ?: '') . '">' . count($call->headers) . ' headers</a>' : '-';
574577
$tables['details']['headers_received'] = $call->responseHeaders ? '<a href="data:application/json;charset=UTF-8;base64,' . base64_encode(json_encode($call->responseHeaders, JSON_PRETTY_PRINT + JSON_UNESCAPED_SLASHES + JSON_UNESCAPED_UNICODE) ?: '') . '">' . count($call->responseHeaders) . ' headers</a>' : '-';
575-
$tables['timing'] = array_map(function (float $v) {
576-
return sprintf('%.2f ms', $v * 1000);
577-
}, $call->timing->toArray());
578-
578+
/** @var ApiCallTiming $timing */
579+
$timing = $call->timing;
580+
$tables['timing'] = [
581+
'nameLookup' => sprintf('%.2f ms', $timing->nameLookup * 1000),
582+
'connect' => sprintf('%.2f ms', $timing->connect * 1000),
583+
'preTransfer' => sprintf('%.2f ms', $timing->preTransfer * 1000),
584+
'startTransfer' => sprintf('%.2f ms', $timing->startTransfer * 1000),
585+
'redirect' => sprintf('%.2f ms', $timing->redirect * 1000),
586+
'total' => sprintf('%.2f ms', $timing->total * 1000),
587+
];
579588
$tables['options'] = $call->options;
580589
foreach ($tables as $table => $fields) {
581590
$t = 0;

0 commit comments

Comments
 (0)