bezrukov/php-project-lvl1

View on GitHub
src/games/even.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

namespace BrainGames\Cli\games\even;

use function BrainGames\Cli\run;

function isEven(int $num)
{
    return $num % 2 === 0;
}

function getGameData()
{
    $question = rand(0, 300);
    $answer = isEven($question) ? 'yes' : 'no';

    return [
        $question, $answer,
    ];
}

function game()
{
    $describeGame = 'Answer "yes" if the number is even, otherwise answer "no".';

    run(
        $describeGame,
        function () {
            return getGameData();
        }
    );
}