DiceGraphic::getString()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 3

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 10
cc 3
nc 4
nop 0
crap 3
1
<?php
2
3
namespace App\Dice;
4
5
class DiceGraphic extends Dice
6
{
7
    /**
8
     * Constant array that contain the graphic representation of a six sided dice.
9
     */
10
    public const GRAPHIC_REPRESENTATION = [
11
        '⚀',
12
        '⚁',
13
        '⚂',
14
        '⚃',
15
        '⚄',
16
        '⚅',
17
    ];
18
19
    /**
20
     * __construct.
21
     *
22
     * Constructor of the class
23
     *
24
     * @return void
25
     */
26 6
    public function __construct()
27
    {
28 6
        parent::__construct();
29
    }
30
31
    /**
32
     * getString.
33
     *
34
     * Return the value of the dice as a graphic representation of a six sided dice
35
     */
36 5
    public function getString(): string
37
    {
38 5
        $value = $this->value;
39
40 5
        return ($value >= 1 and $value <= 6) ? self::GRAPHIC_REPRESENTATION[$value - 1] : parent::getString();
41
    }
42
}
43