Skip to content

Commit dee1987

Browse files
committed
project check. ALL edition(2)
1 parent a483205 commit dee1987

File tree

7 files changed

+15
-18
lines changed

7 files changed

+15
-18
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Thumbs.db
2323
composer
2424
composer.bat
2525
composer.phar
26+
composer.lock
2627
phpcbf.phar
2728
phpcs.phar
2829
video.cast

src/Engine.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function getUserName(): string
1515
return $name;
1616
}
1717
//---Функция логики игры и проверки ответов
18-
function startGame(array $gameParams)
18+
function startGame(array $gameParams): void
1919
{
2020
$name = getUserName();
2121
["rules" => $rules,
@@ -25,7 +25,7 @@ function startGame(array $gameParams)
2525
for ($i = 0; $i < count($questions); $i++) {
2626
$answer = prompt("Question: {$questions[$i]}");
2727
line("Your answer: {$answer}");
28-
if ($answer != $expectedAnswer[$i]) {
28+
if ($answer !== $expectedAnswer[$i]) {
2929
wrongAnswer($name, $answer, $expectedAnswer[$i]);
3030
return;
3131
} else {
@@ -35,14 +35,14 @@ function startGame(array $gameParams)
3535
trueAnswers($name);
3636
}
3737
//---Функция для неверного ответа
38-
function wrongAnswer(string $name, mixed $answer, mixed $expectedAnswer)
38+
function wrongAnswer(string $name, mixed $answer, mixed $expectedAnswer): void
3939
{
4040
line("{$answer} is wrong answer ;(. Correct answer was '{$expectedAnswer}'.");
4141
line("Let's try again, %s!", $name);
4242
return;
4343
}
4444
//---Функция для верного ответа (конец игры)
45-
function trueAnswers(string $name)
45+
function trueAnswers(string $name): void
4646
{
4747
line("Congratulations, %s!", $name);
4848
return;

src/Games/Calc.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use function BrainGames\Engine\startGame;
66

77
//-- Игра - "Калькулятор"
8-
function initGameData($count = 3): void
8+
function initGameData(int $count = 3): void
99
{
1010
$gameParams = [];
1111
$gameParams["rules"] = 'What is the result of the expression?';
@@ -21,7 +21,7 @@ function initGameData($count = 3): void
2121
startGame($gameParams);
2222
}
2323

24-
function calculate($x, $y, $operator)
24+
function calculate(int $x, int $y, string $operator): int
2525
{
2626
$operations = [
2727
'+' => fn($x, $y) => $x + $y,

src/Games/Even.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@
55
use function BrainGames\Engine\startGame;
66

77
//-- Игра - "Проверка на чётность"
8-
function initGameData(): void
8+
function initGameData(int $count = 3): void
99
{
1010
$gameParams = [];
1111
$gameParams["rules"] = 'Answer "yes" if the number is even, otherwise answer "no".';
12-
$count = 3;
1312
for ($counterAnswers = 0; $counterAnswers < $count; $counterAnswers++) {
1413
$num = random_int(1, 100);
1514
$gameParams["expectedAnswer"][] = isEven($num) ? "yes" : "no";

src/Games/Gcd.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@
55
use function BrainGames\Engine\startGame;
66

77
//-- Игра - Общий делитель -- "НОД"
8-
function initGameData(): void
8+
function initGameData(int $count = 3): void
99
{
1010
$gameParams = [];
1111
$gameParams["rules"] = 'Find the greatest common divisor of given numbers.';
12-
$count = 3;
1312
for ($counterAnswers = 0; $counterAnswers < $count; $counterAnswers++) {
1413
$num = random_int(1, 100);
1514
$num2 = random_int(1, 100);
@@ -25,7 +24,7 @@ function getGcd(int $num1, int $num2): int
2524
{
2625
$a = $num1;
2726
$b = $num2;
28-
while ($b != 0) {
27+
while ($b !== 0) {
2928
$temp = $b;
3029
$b = $a % $b;
3130
$a = $temp;

src/Games/Prime.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@
55
use function BrainGames\Engine\startGame;
66

77
//-- Игра - "Простое ли число?"
8-
function initGameData(): void
8+
function initGameData(int $count = 3): void
99
{
1010
$gameParams = [];
1111
$gameParams["rules"] = 'Answer "yes" if given number is prime. Otherwise answer "no".';
12-
$count = 3;
1312
for ($counterAnswers = 0; $counterAnswers < $count; $counterAnswers++) {
1413
$num = random_int(1, 100);
1514
$gameParams["expectedAnswer"][] = isPrime($num) ? 'yes' : 'no';
@@ -26,16 +25,16 @@ function isPrime(int $number): bool
2625
return false;
2726
}
2827

29-
if ($number == 2) {
28+
if ($number === 2) {
3029
return true;
3130
}
3231

33-
if ($number % 2 == 0) {
32+
if ($number % 2 === 0) {
3433
return false;
3534
}
3635

3736
for ($i = 3; $i <= sqrt($number); $i += 2) {
38-
if ($number % $i == 0) {
37+
if ($number % $i === 0) {
3938
return false;
4039
}
4140
}

src/Games/Progression.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@
55
use function BrainGames\Engine\startGame;
66

77
//-- Игра - "Арифметическая прогрессия"
8-
function initGameData(): void
8+
function initGameData(int $count = 3): void
99
{
1010
$gameParams = [];
1111
$gameParams["rules"] = 'What number is missing in the progression?';
12-
$count = 3;
1312
for ($counterAnswers = 0; $counterAnswers < $count; $counterAnswers++) {
1413
$progression = generateProgression();
1514
$hiddenElement = hideElement($progression);

0 commit comments

Comments
 (0)