Player   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 67
ccs 22
cts 22
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 15 1
A createFromArray() 0 18 1
1
<?php
2
3
namespace PtrTn\Battlerite\Dto\Match;
4
5
use Webmozart\Assert\Assert;
6
7
class Player
8
{
9
    /**
10
     * @var string
11
     */
12
    public $type;
13
14
    /**
15
     * @var string
16
     */
17
    public $id;
18
19
    /**
20
     * @var string
21
     */
22
    public $name;
23
24
    /**
25
     * @var string
26
     */
27
    public $patchVersion;
28
29
    /**
30
     * @var string
31
     */
32
    public $shardId;
33
34
    /**
35
     * @var string
36
     */
37
    public $titleId;
38
39 11
    private function __construct(
40
        string $type,
41
        string $id,
42
        string $name,
43
        string $patchVersion,
44
        string $shardId,
45
        string $titleId
46
    ) {
47 11
        $this->type = $type;
48 11
        $this->id = $id;
49 11
        $this->name = $name;
50 11
        $this->patchVersion = $patchVersion;
51 11
        $this->shardId = $shardId;
52 11
        $this->titleId = $titleId;
53 11
    }
54
55 11
    public static function createFromArray(array $player): self
56
    {
57 11
        Assert::string($player['type']);
58 11
        Assert::string($player['id']);
59 11
        Assert::string($player['attributes']['name']);
60 11
        Assert::string($player['attributes']['patchVersion']);
61 11
        Assert::string($player['attributes']['shardId']);
62 11
        Assert::string($player['attributes']['titleId']);
63
64 11
        return new self(
65 11
            $player['type'],
66 11
            $player['id'],
67 11
            $player['attributes']['name'],
68 11
            $player['attributes']['patchVersion'],
69 11
            $player['attributes']['shardId'],
70 11
            $player['attributes']['titleId']
71
        );
72
    }
73
}
74