Skip to content

Commit

Permalink
add type parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
Egorskov committed Oct 15, 2024
1 parent dfcc2b0 commit 8a9be41
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Engine.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
const MIN_NUM = 1;
const MAX_NUM = 100;

function communication(array $answers, $game): void
function communication(array $answers, string $game): void
{
$name = greeting();
line("$game");
Expand Down
5 changes: 1 addition & 4 deletions src/Games/Calc.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,14 @@ function calc(): void
}
communication($answers, $game);
}
function calculate($num1, $num2, $operation)
function calculate(int $num1, int $num2, string $operation)
{
switch ($operation) {
case '+':
return $num1 + $num2;
break;
case '-':
return $num1 - $num2;
break;
case '*':
return $num1 * $num2;
break;
}
}
2 changes: 1 addition & 1 deletion src/Games/Even.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function even(): void
communication($answers, $game);
}

function isEven($num): bool
function isEven(int $num): bool
{
return $num % 2 === 0;
}
2 changes: 1 addition & 1 deletion src/Games/GCD.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function gcd(): void
communication($answers, $game);
}

function nod($x, $y)
function nod(int $x, int $y)
{
while ($x != 0 && $y != 0) {
if ($x >= $y) {
Expand Down

0 comments on commit 8a9be41

Please sign in to comment.