Skip to content

Commit b334d7a

Browse files
committed
fix: collection methods can return null so need to cast as float
1 parent 3ed2e46 commit b334d7a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Command/Environment/GetEnvironmentMetricsCommand.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,28 +68,28 @@ protected function perform(InputInterface $input, ConsoleOutput $output)
6868
if (!empty($metrics['cdn'])) {
6969
$headers = array_merge($headers, [new TableSeparator(), 'Content Delivery Network', '']);
7070
$row1 = array_merge($row1, [new TableSeparator(), 'Bandwidth used', 'Requests']);
71-
$row2 = array_merge($row2, [new TableSeparator(), number_format(collect($metrics['cdn']['bandwidth'])->sum() / 1000000000, 2).'GB', number_format(collect($metrics['cdn']['requests'])->sum())]);
71+
$row2 = array_merge($row2, [new TableSeparator(), number_format((float) collect($metrics['cdn']['bandwidth'])->sum() / 1000000000, 2).'GB', number_format((float) collect($metrics['cdn']['requests'])->sum())]);
7272
$row3 = array_merge($row3, [new TableSeparator(), '$'.number_format($metrics['cdn']['cost_bandwidth'], 2), '$'.number_format($metrics['cdn']['cost_requests'], 2)]);
7373
$total += $metrics['cdn']['cost_bandwidth'] + $metrics['cdn']['cost_requests'];
7474
}
7575
if (!empty($metrics['gateway'])) {
7676
$headers = array_merge($headers, [new TableSeparator(), 'API Gateway']);
7777
$row1 = array_merge($row1, [new TableSeparator(), 'Requests']);
78-
$row2 = array_merge($row2, [new TableSeparator(), number_format(collect($metrics['gateway']['requests'])->sum())]);
78+
$row2 = array_merge($row2, [new TableSeparator(), number_format((float) collect($metrics['gateway']['requests'])->sum())]);
7979
$row3 = array_merge($row3, [new TableSeparator(), '$'.number_format($metrics['gateway']['cost_requests'], 2)]);
8080
$total += $metrics['gateway']['cost_requests'];
8181
}
8282
if (!empty($metrics['website'])) {
8383
$headers = array_merge($headers, [new TableSeparator(), 'Website Lambda function', '', '']);
8484
$row1 = array_merge($row1, [new TableSeparator(), 'Invocations', 'Duration', 'Avg duration']);
85-
$row2 = array_merge($row2, [new TableSeparator(), number_format(collect($metrics['website']['invocations'])->sum()), number_format(collect($metrics['website']['duration'])->sum() / 1000).'s', number_format(collect($metrics['website']['avg_duration'])->avg()).'ms']);
85+
$row2 = array_merge($row2, [new TableSeparator(), number_format((float) collect($metrics['website']['invocations'])->sum()), number_format((float) collect($metrics['website']['duration'])->sum() / 1000).'s', number_format((float) collect($metrics['website']['avg_duration'])->avg()).'ms']);
8686
$row3 = array_merge($row3, [new TableSeparator(), '$'.number_format($metrics['website']['cost_invocations'], 2), '$'.number_format($metrics['website']['cost_duration'], 2), '-']);
8787
$total += $metrics['website']['cost_duration'] + $metrics['website']['cost_invocations'];
8888
}
8989
if (!empty($metrics['console'])) {
9090
$headers = array_merge($headers, [new TableSeparator(), 'Console Lambda function', '', '']);
9191
$row1 = array_merge($row1, [new TableSeparator(), 'Invocations', 'Duration', 'Avg duration']);
92-
$row2 = array_merge($row2, [new TableSeparator(), number_format(collect($metrics['console']['invocations'])->sum()), number_format(collect($metrics['console']['duration'])->sum() / 1000).'s', number_format(collect($metrics['console']['avg_duration'])->avg()).'ms']);
92+
$row2 = array_merge($row2, [new TableSeparator(), number_format((float) collect($metrics['console']['invocations'])->sum()), number_format((float) collect($metrics['console']['duration'])->sum() / 1000).'s', number_format((float) collect($metrics['console']['avg_duration'])->avg()).'ms']);
9393
$row3 = array_merge($row3, [new TableSeparator(), '$'.number_format($metrics['console']['cost_invocations'], 2), '$'.number_format($metrics['console']['cost_duration'], 2), '-']);
9494
$total += $metrics['console']['cost_duration'] + $metrics['console']['cost_invocations'];
9595
}

0 commit comments

Comments
 (0)