Skip to content

Commit

Permalink
refactor: isolate greeting to function
Browse files Browse the repository at this point in the history
  • Loading branch information
kolotov committed Aug 26, 2023
1 parent 635f086 commit debf1ff
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
5 changes: 3 additions & 2 deletions bin/brain-games
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env docker-compose run php
<?php

require_once './vendor/autoload.php';
require_once './src/Cli.php';
use function BrainGames\Cli\greeting;

greeting();
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
"autoload": {
"psr-4": {
"BrainGames\\": "src/"
}
},
"files": [
"src/Cli.php"
]
},
"authors": [
{
Expand Down
9 changes: 6 additions & 3 deletions src/Cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
use function cli\line;
use function cli\prompt;

line('Welcome to the Brain Game!');
$name = prompt('May I have your name?');
line("Hello, %s!", $name);
function greeting(): void
{
line('Welcome to the Brain Game!');
$name = prompt('May I have your name?');
line("Hello, %s!", $name);
}

0 comments on commit debf1ff

Please sign in to comment.