Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 7 |
| Rasb14\T100\Dice | |
0.00% |
0 / 1 |
|
0.00% |
0 / 4 |
20.00 | |
0.00% |
0 / 7 |
| __construct | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 2 |
|||
| roll | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 3 |
|||
| value | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 1 |
|||
| getHistogramMax | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 1 |
|||
| <?php | |
| namespace Rasb14\T100; | |
| /** | |
| * Dice, a class representing a real world dice. | |
| */ | |
| class Dice implements IHistogram | |
| { | |
| use THistogram; | |
| /** | |
| * @var int $value The current value of the die. | |
| * @var int $sides The number of sides of the die. | |
| */ | |
| protected $value; | |
| private $sides; | |
| /** | |
| * Constructor to create a Dice. | |
| * | |
| * @param int $sides The number of sides of the die. | |
| */ | |
| public function __construct(int $sides = 6) | |
| { | |
| $this->sides = $sides; | |
| } | |
| /** | |
| * Rolls the die. | |
| * | |
| * @return int as the current value of the die. | |
| */ | |
| public function roll() | |
| { | |
| $this->value = rand(1, $this->sides); | |
| $this->sequence[] = $this->value; | |
| return $this->value; | |
| } | |
| /** | |
| * Gets the current value of the upfacing side of the die. | |
| * | |
| * @return int as the current value of the die. | |
| */ | |
| public function value() | |
| { | |
| return $this->value; | |
| } | |
| /** | |
| * Gets the maximum value for the histogram. | |
| * | |
| * @return int as the maximum value. | |
| */ | |
| public function getHistogramMax() | |
| { | |
| return $this->sides; | |
| } | |
| } |