itohin/project-lvl1-s426

View on GitHub
src/Games/IsEven.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

namespace BrainGames\Games\IsEven;

use function BrainGames\Kernel\game;

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

function run()
{
    $getGameData = function () {
        $question = rand(1, 99);
        $correct = isEven($question) ? 'yes' : 'no';

        return [$question, $correct];
    };
    game(TASK_OF_GAME, $getGameData);
}

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