Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
100.00% |
1 / 1 |
|
100.00% |
4 / 4 |
CRAP | |
100.00% |
7 / 7 |
| Rasb14\T100\Dice | |
100.00% |
1 / 1 |
|
100.00% |
4 / 4 |
4 | |
100.00% |
7 / 7 |
| __construct | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
| roll | |
100.00% |
1 / 1 |
1 | |
100.00% |
3 / 3 |
|||
| value | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
| getHistogramMax | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 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; | |
| } | |
| } |