Rustam-Amirov/php-project-lvl1

View on GitHub
src/Games/Even.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

namespace BrainGames\Games\Even;

use function BrainGames\Core\run;

const GAME_RULE = 'Answer "yes" if number even otherwise answer "no".';

function even()
{
    $getGameData = function () {
        $question = rand(1, 100);
        $correctAnswer = isEven($num) ? 'yes' : 'no';
        return [
            'question' => $question,
            'correctAnswer' => $correctAnswer
        ];
    };
    run($getGameData, GAME_RULE);
}
function isEven($num)
{
    return ($num % 2 == 0);
}