Dice Roller


Purpose

The purpose of this test is to evaluate the way you think about and solve problems
using PHP. Submitted code must be functional and designed well. Comments
are required and should be written using traditional doc block syntax (http://
www.phpdoc.org/).

The Project

Create a dice roller that can be executed via shell command and echo out the
response.

Roller Requirements

The shell command will accept one string argument. The string argument will be
in the format {digit}d{digit} where the first digit represents the number of dice
and the second digit represents the number of sides. So if the string argument was
1d6 I would expect a resulting random number 1-6. If the argument was 3d6, 3 six
sided dice would be rolled with the result being a random number 3-18.
Execute the code on the shell like so:
bash: php roll 3d6
bash: 18
The code must be able to roll dice for any number of sides and any number of dice
and echo the result directly to the screen. Your code must handle and sanitize bad
user input gracefully.
You will not be evaluated for code meant to handle finding the PHP binary across
platforms. So don’t write code for it.
PHP Requirements
Should be written using PHP 5.3.x object oriented syntax (no procedural code)
Demonstrate use of method keywords (public, protected, private, final)
Code should parse, be functional and run without errors of any kind in strict mode.

Solution

dice_roll.zip