CardGraphic::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 2
dl 0
loc 4
rs 10
ccs 3
cts 3
cp 1
crap 1
1
<?php
2
3
namespace App\Card;
4
5
class CardGraphic extends Card
6
{
7
    private $representation;
8
9 26
    public function __construct($suit, $value)
10
    {
11 26
        parent::__construct($suit, $value);
12 26
        $this->representation = $this->generateRepresentation();
13
    }
14
15 26
    private function generateRepresentation(): string
16
    {
17 26
        $symbols = [
18 26
            'Hearts'   => '♥',
19 26
            'Diamonds' => '♦',
20 26
            'Clubs'    => '♣',
21 26
            'Spades'   => '♠',
22 26
        ];
23
24 26
        return $symbols[$this->suit] . $this->value;
25
    }
26
27 1
    public function getAsString(): string
28
    {
29 1
        return $this->representation;
30
    }
31
}
32