nurgeld/project-lvl1-s384

View on GitHub
src/games/Even.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

namespace BrainGames\games\Even;

use function BrainGames\Cli\play;

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

function run()
{
    $gamePromt = 'Answer "yes" if number even otherwise answer "no".';
    
    $even = function () {
        $question = rand(1, 100);
        $correctAnswer = isEven($question) ? 'yes' : 'no';

        return [$question, $correctAnswer];
    };

    play($gamePromt, $even);
}