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