DiceGraphic::getAsString()   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
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
namespace App\Dice;
4
5
/**
6
 * Class DiceGraphic
7
 *
8
 * Extends the Dice class to represent the dice value using Unicode dice face characters.
9
 */
10
class DiceGraphic extends Dice
11
{
12
    /**
13
     * Unicode representations of dice faces for values 1 to 6.
14
     *
15
     * @var string[]
16
     */
17
    /** @var string[] */
18
    private $representation = [
19
        '⚀',
20
        '⚁',
21
        '⚂',
22
        '⚃',
23
        '⚄',
24
        '⚅',
25
    ];
26
27
    /**
28
     * DiceGraphic constructor.
29
     */
30 2
    public function __construct()
31
    {
32 2
        parent::__construct();
33
    }
34
35
    /**
36
     * Get the graphical string representation of the current dice value.
37
     *
38
     * @return string Unicode character representing the dice face.
39
     */
40 1
    public function getAsString(): string
41
    {
42 1
        return $this->representation[$this->value - 1];
43
    }
44
}
45