ljapkin-roman/php-project-lvl1

View on GitHub
src/Games/even.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php
namespace Ogurchik\Games\even;

use function Ogurchik\Engine\engine;

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

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

function launch()
{
    $generateData = function () {
        $question = rand();
        $data['question'] = $question;
        $data['correctAnswer'] =  isEven($question) ? "no" : "yes";
        return $data;
    };
    engine(DESCRIPTION, $generateData);
}