Skip to content

Commit 57fa95e

Browse files
CopilotThavarshan
andcommitted
Fix code review feedback: correct time_to_first_byte calculation and simplify withDebug logic
Co-authored-by: Thavarshan <10804999+Thavarshan@users.noreply.github.com>
1 parent e5897d5 commit 57fa95e

3 files changed

Lines changed: 3 additions & 7 deletions

File tree

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"friendsofphp/php-cs-fixer": "^3.64",
3939
"laravel/pint": "^1.21",
4040
"mockery/mockery": "^1.6",
41+
"phpstan/phpstan": "^1.11.5",
4142
"phpunit/phpunit": "^11.5",
4243
"squizlabs/php_codesniffer": "^3.7",
4344
"symfony/var-dumper": "^6.0|^7.2",

src/Fetch/Concerns/ManagesDebugAndProfiling.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,7 @@ trait ManagesDebugAndProfiling
4545
public function withDebug(array|bool $options = true): static
4646
{
4747
$this->debugEnabled = $options !== false;
48-
49-
if (is_array($options)) {
50-
$this->debugOptions = array_merge(DebugInfo::getDefaultOptions(), $options);
51-
} else {
52-
$this->debugOptions = DebugInfo::getDefaultOptions();
53-
}
48+
$this->debugOptions = array_merge(DebugInfo::getDefaultOptions(), is_array($options) ? $options : []);
5449

5550
return $this;
5651
}

src/Fetch/Support/FetchProfiler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ protected function calculateMetrics(string $requestId): array
266266
}
267267

268268
if (isset($events['request_sent'])) {
269-
$metrics['time_to_first_byte'] = round(($events['response_start'] ?? $endTime - $events['request_sent']) * 1000, 3);
269+
$metrics['time_to_first_byte'] = round((($events['response_start'] ?? $endTime) - $events['request_sent']) * 1000, 3);
270270
}
271271

272272
// Include raw events for detailed analysis

0 commit comments

Comments
 (0)