Completed
Pull Request — master (#4)
by Peter
02:12
created

Team   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 159
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
B __construct() 0 35 1
B createFromArray() 0 37 1
1
<?php
2
3
namespace PtrTn\Battlerite\Dto\Teams;
4
5
use DateTime;
6
use PtrTn\Battlerite\Assert\Assert;
7
8
class Team
9
{
10
    /**
11
     * @var string
12
     */
13
    public $type;
14
15
    /**
16
     * @var string
17
     */
18
    public $id;
19
20
    /**
21
     * @var string
22
     */
23
    public $titleId;
24
25
    /**
26
     * @var string
27
     */
28
    public $name;
29
30
    /**
31
     * @var string
32
     */
33
    public $shardId;
34
35
    /**
36
     * @var int
37
     */
38
    public $avatar;
39
40
    /**
41
     * @var int
42
     */
43
    public $division;
44
45
    /**
46
     * @var int
47
     */
48
    public $divisionRating;
49
50
    /**
51
     * @var int
52
     */
53
    public $league;
54
55
    /**
56
     * @var int
57
     */
58
    public $losses;
59
60
    /**
61
     * @var Members
62
     */
63
    public $members;
64
65
    /**
66
     * @var int
67
     */
68
    public $placementGamesLeft;
69
70
    /**
71
     * @var int
72
     */
73
    public $topDivision;
74
75
    /**
76
     * @var int
77
     */
78
    public $topDivisionRating;
79
80
    /**
81
     * @var int
82
     */
83
    public $topLeague;
84
85
    /**
86
     * @var int
87
     */
88
    public $wins;
89
90
    /**
91
     * @SuppressWarnings(PHPMD.ExcessiveParameterList)
92
     */
93 1
    private function __construct(
94
        string $type,
95
        string $id,
96
        string $name,
97
        string $shardId,
98
        int $avatar,
99
        int $division,
100
        int $divisionRating,
101
        int $league,
102
        int $losses,
103
        Members $members,
104
        int $placementGamesLeft,
105
        int $topDivision,
106
        int $topDivisionRating,
107
        int $topLeague,
108
        int $wins,
109
        string $titleId
110
    ) {
111 1
        $this->type = $type;
112 1
        $this->id = $id;
113 1
        $this->name = $name;
114 1
        $this->shardId = $shardId;
115 1
        $this->avatar = $avatar;
116 1
        $this->division = $division;
117 1
        $this->divisionRating = $divisionRating;
118 1
        $this->league = $league;
119 1
        $this->losses = $losses;
120 1
        $this->members = $members;
121 1
        $this->placementGamesLeft = $placementGamesLeft;
122 1
        $this->topDivision = $topDivision;
123 1
        $this->topDivisionRating = $topDivisionRating;
124 1
        $this->topLeague = $topLeague;
125 1
        $this->wins = $wins;
126 1
        $this->titleId = $titleId;
127 1
    }
128
129 1
    public static function createFromArray(array $match): self
130
    {
131 1
        Assert::string($match['type']);
132 1
        Assert::string($match['id']);
133 1
        Assert::string($match['attributes']['name']);
134 1
        Assert::string($match['attributes']['shardId']);
135 1
        Assert::integer($match['attributes']['stats']['avatar']);
136 1
        Assert::integer($match['attributes']['stats']['division']);
137 1
        Assert::integer($match['attributes']['stats']['divisionRating']);
138 1
        Assert::integer($match['attributes']['stats']['league']);
139 1
        Assert::integer($match['attributes']['stats']['losses']);
140 1
        Assert::integer($match['attributes']['stats']['placementGamesLeft']);
141 1
        Assert::integer($match['attributes']['stats']['topDivision']);
142 1
        Assert::integer($match['attributes']['stats']['topDivisionRating']);
143 1
        Assert::integer($match['attributes']['stats']['topLeague']);
144 1
        Assert::integer($match['attributes']['stats']['wins']);
145 1
        Assert::string($match['attributes']['titleId']);
146
147 1
        return new self(
148 1
            $match['type'],
149 1
            $match['id'],
150 1
            $match['attributes']['name'],
151 1
            $match['attributes']['shardId'],
152 1
            $match['attributes']['stats']['avatar'],
153 1
            $match['attributes']['stats']['division'],
154 1
            $match['attributes']['stats']['divisionRating'],
155 1
            $match['attributes']['stats']['league'],
156 1
            $match['attributes']['stats']['losses'],
157 1
            Members::createFromArray($match['attributes']['stats']['members']),
158 1
            $match['attributes']['stats']['placementGamesLeft'],
159 1
            $match['attributes']['stats']['topDivision'],
160 1
            $match['attributes']['stats']['topDivisionRating'],
161 1
            $match['attributes']['stats']['topLeague'],
162 1
            $match['attributes']['stats']['wins'],
163 1
            $match['attributes']['titleId']
164
        );
165
    }
166
}
167