Skip to content

Commit

Permalink
step 5 preparing files
Browse files Browse the repository at this point in the history
  • Loading branch information
Roman52 committed Jan 3, 2021
1 parent ff6a3e6 commit 4f0396a
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ validate:
brain-games:
php bin/brain-games

brain-even:
php bin/brain-even

lint:
composer run-script phpcs -- --standard=PSR12 src bin

15 changes: 15 additions & 0 deletions bin/brain-even
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env php

<?php

use function Brain\Games\IfEven\evenCheck;

$autoloadPath1 = __DIR__ . '/../../../autoload.php';
$autoloadPath2 = __DIR__ . '/../vendor/autoload.php';
if (file_exists($autoloadPath1)) {
require_once $autoloadPath1;
} else {
require_once $autoloadPath2;
}

evenCheck();
8 changes: 6 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"name": "hexlet/code",
"bin": ["bin/brain-games"],
"bin": [
"bin/brain-games",
"bin/brain-even"
],
"type": "library",
"authors": [
{
Expand All @@ -12,7 +15,8 @@
"license": "MIT",
"autoload": {
"files": [
"src/Cli.php"
"src/Cli.php",
"src/EvenCheck.php"
]
},
"scripts": {
Expand Down
16 changes: 16 additions & 0 deletions src/EvenCheck.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace Brain\Games\IfEven;

use function cli\line;
use function cli\prompt;

function evenCheck()
{
line('Welcome to the Brain Games!');
$name = prompt('May I have your name?');
line("Hello, %s!", $name);
line('Answer "yes" if the number is even, otherwise answer "no".');
line('Question: 15');
$answer = prompt('Your answer');
}

0 comments on commit 4f0396a

Please sign in to comment.