Completed
Push — master ( 00502f...bef3d5 )
by Steve
03:34
created

BasicDice::name()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
4
namespace MeadSteve\DiceApi;
5
6
class BasicDice implements Dice
7
{
8
9
    private $size;
10
11
    public function __construct(int $size)
12
    {
13
        $this->size = $size;
14
    }
15
16
    public function name()
17
    {
18
        return "d{$this->size}";
19
    }
20
21
    public function roll()
22
    {
23
        if (! function_exists('random_int')) {
24
            return mt_rand(1, $this->size);
25
        }
26
27
        return random_int(1, $this->size);
28
    }
29
}
30