DiceGraphic::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
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