Passed
Push — master ( 782176...fdfe0b )
by Peter
44s
created

StatMapping::createFromArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 9.4285
cc 1
eloc 5
nc 1
nop 1
crap 1
1
<?php
2
3
namespace PtrTn\Battlerite\Repository\Dto;
4
5
class StatMapping
6
{
7
    /**
8
     * @var string
9
     */
10
    public $statName;
11
12
    /**
13
     * @var null|string
14
     */
15
    public $champion;
16
17
    /**
18
     * @var null|string
19
     */
20
    public $map;
21
22 3
    public function __construct(string $name, ?string $champion, ?string $map)
23
    {
24 3
        $this->statName = $name;
25 3
        $this->champion = $champion;
26 3
        $this->map = $map;
27 3
    }
28
29 3
    public static function createFromArray(array $statData): self
30
    {
31 3
        return new self(
32 3
            $statData['stat'],
33 3
            $statData['champion'] ?? null,
34 3
            $statData['map'] ?? null
35
        );
36
    }
37
38 2
    public function isChampionStat(): bool
39
    {
40 2
        return isset($this->champion);
41
    }
42
43 1
    public function isMapStat(): bool
44
    {
45 1
        return isset($this->map);
46
    }
47
}
48