Skip to content

Commit d8bfd17

Browse files
committed
fixed bin files/added 'use', minor fixes ingame files/ Even Gcd, moved autolaod files in json after bin
1 parent f795c07 commit d8bfd17

File tree

9 files changed

+26
-21
lines changed

9 files changed

+26
-21
lines changed

bin/brain-calc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33

44
$autoloadPath1 = __DIR__ . '/../../../autoload.php';
55
$autoloadPath2 = __DIR__ . '/../vendor/autoload.php';
6+
use function BrainGames\Games\Calc\runGame;
67

78
if (file_exists($autoloadPath1)) {
89
require_once $autoloadPath1;
910
} else {
1011
require_once $autoloadPath2;
1112
}
1213

13-
BrainGames\Games\Calc\runGame();
14+
runGame();

bin/brain-even

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33

44
$autoloadPath1 = __DIR__ . '/../../../autoload.php';
55
$autoloadPath2 = __DIR__ . '/../vendor/autoload.php';
6+
use function BrainGames\Games\Even\runGame;
67

78
if (file_exists($autoloadPath1)) {
89
require_once $autoloadPath1;
910
} else {
1011
require_once $autoloadPath2;
1112
}
1213

13-
BrainGames\Games\Even\runGame();
14+
runGame();
1415

1516

1617

bin/brain-games

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33

44
$autoloadPath1 = __DIR__ . '/../../../autoload.php';
55
$autoloadPath2 = __DIR__ . '/../vendor/autoload.php';
6+
use function BrainGames\Cli\welcome;
67

78
if (file_exists($autoloadPath1)) {
89
require_once $autoloadPath1;
910
} else {
1011
require_once $autoloadPath2;
1112
}
1213

13-
BrainGames\Cli\welcome();
14+
welcome();

bin/brain-gcd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33

44
$autoloadPath1 = __DIR__ . '/../../../autoload.php';
55
$autoloadPath2 = __DIR__ . '/../vendor/autoload.php';
6+
use function BrainGames\Games\Gcd\runGame;
67

78
if (file_exists($autoloadPath1)) {
89
require_once $autoloadPath1;
910
} else {
1011
require_once $autoloadPath2;
1112
}
1213

13-
BrainGames\Games\Gcd\runGame();
14+
runGame();

bin/brain-prime

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33

44
$autoloadPath1 = __DIR__ . '/../../../autoload.php';
55
$autoloadPath2 = __DIR__ . '/../vendor/autoload.php';
6+
use function BrainGames\Games\Prime\runGame;
67

78
if (file_exists($autoloadPath1)) {
89
require_once $autoloadPath1;
910
} else {
1011
require_once $autoloadPath2;
1112
}
1213

13-
BrainGames\Games\Prime\runGame();
14+
runGame();

bin/brain-progression

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33

44
$autoloadPath1 = __DIR__ . '/../../../autoload.php';
55
$autoloadPath2 = __DIR__ . '/../vendor/autoload.php';
6+
use function BrainGames\Games\Progression\runGame;
67

78
if (file_exists($autoloadPath1)) {
89
require_once $autoloadPath1;
910
} else {
1011
require_once $autoloadPath2;
1112
}
1213

13-
BrainGames\Games\Progression\runGame();
14+
runGame();

composer.json

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,6 @@
2020
"bin/brain-progression",
2121
"bin/brain-prime"
2222
],
23-
24-
"require-dev": {
25-
"squizlabs/php_codesniffer": "^4.0"
26-
},
27-
"scripts": {
28-
"phpcs": "phpcs --standard=PSR12 src bin",
29-
"phpcbf": "phpcbf --standard=PSR12 src bin"
30-
},
3123
"autoload": {
3224
"files": [
3325
"src/Engine.php",
@@ -38,5 +30,12 @@
3830
"src/Games/Prime.php",
3931
"src/Games/Progression.php"
4032
]
33+
},
34+
"require-dev": {
35+
"squizlabs/php_codesniffer": "^4.0"
36+
},
37+
"scripts": {
38+
"phpcs": "phpcs --standard=PSR12 src bin",
39+
"phpcbf": "phpcbf --standard=PSR12 src bin"
4140
}
4241
}

src/Games/Even.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@
66

77
const RULES = 'Answer "yes" if the number is even, otherwise answer "no".';
88

9-
function isEven(int $number): bool
10-
{
11-
return $number % 2 === 0;
12-
}
13-
149
function runGame(): void
1510
{
1611
$generateData = function () {
@@ -26,3 +21,8 @@ function runGame(): void
2621

2722
runEngine($generateData, RULES);
2823
}
24+
25+
function isEven(int $number): bool
26+
{
27+
return $number % 2 === 0;
28+
}

src/Games/Gcd.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function runGame(): void
1919
}
2020

2121
$question = "$a $b";
22-
$answer = gcd($a, $b);
22+
$answer = getGcd($a, $b);
2323

2424
return [
2525
'question' => $question,
@@ -30,7 +30,7 @@ function runGame(): void
3030
runEngine($generateData, RULES);
3131
}
3232

33-
function gcd(int $a, int $b): int
33+
function getGcd(int $a, int $b): int
3434
{
3535
while ($b !== 0) {
3636
[$a, $b] = [$b, $a % $b];

0 commit comments

Comments
 (0)