Skip to content

Commit f3ffe16

Browse files
committed
Fix psalm errors.
Use more verbose code style to get typing to be more sound.
1 parent fdbe12c commit f3ffe16

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/Command/BenchmarkCommand.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,21 @@ public function execute(Arguments $args, ConsoleIo $io): ?int
5050
$this->io = $io;
5151
/** @var string $url */
5252
$url = $args->getArgumentAt(0);
53-
$defaults = ['t' => 100, 'n' => 10];
54-
$options = array_merge($defaults, $args->getOptions());
5553
$times = [];
5654

5755
$io->out(Text::insert('-> Testing :url', compact('url')));
5856
$io->out('');
59-
for ($i = 0; $i < $options['n']; $i++) {
60-
/** @psalm-suppress PossiblyInvalidOperand */
61-
if (floor($options['t'] - array_sum($times)) <= 0 || $options['n'] <= 1) {
57+
$count = 10;
58+
if ($args->hasOption('n')) {
59+
$count = (float)$args->getOption('n');
60+
}
61+
$timeout = 100;
62+
if ($args->hasOption('t')) {
63+
$timeout = (float)$args->getOption('t');
64+
}
65+
66+
for ($i = 0; $i < $count; $i++) {
67+
if (floor($timeout - array_sum($times)) <= 0 || $count <= 1) {
6268
break;
6369
}
6470

0 commit comments

Comments
 (0)