Make HttpResponseBuilder use the Stringable implementation of Timings.

This commit is contained in:
flash 2025-04-03 15:42:01 +00:00
parent 16e9676430
commit c2bcb0611b
Signed by: flash
GPG key ID: 2C9C2C574D47FE3E
2 changed files with 3 additions and 15 deletions

View file

@ -1 +1 @@
0.2504.31518
0.2504.31541

View file

@ -1,7 +1,7 @@
<?php
// HttpResponseBuilder.php
// Created: 2022-02-08
// Updated: 2025-03-12
// Updated: 2025-04-03
namespace Index\Http;
@ -191,19 +191,7 @@ final class HttpResponseBuilder extends HttpMessageBuilder {
* @param Timings $timings Timings to supply to the devtools.
*/
public function setServerTiming(Timings $timings): void {
$laps = $timings->laps;
$timings = [];
foreach($laps as $lap) {
$timing = $lap->name;
if(!empty($lap->comment))
$timing .= ';desc="' . strtr($lap->comment, ['"' => '\\"']) . '"';
$timing .= ';dur=' . round($lap->durationTime, 5);
$timings[] = $timing;
}
$this->setHeader('Server-Timing', implode(', ', $timings));
$this->setHeader('Server-Timing', (string)$timings);
}
/**