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

StatMapping   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 2
cbo 0
dl 0
loc 43
ccs 14
cts 14
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A createFromArray() 0 8 1
A isChampionStat() 0 4 1
A isMapStat() 0 4 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