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

Stats::createFromArray()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 34
Code Lines 31

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 27
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 34
ccs 27
cts 27
cp 1
rs 8.8571
cc 1
eloc 31
nc 1
nop 3
crap 1
1
<?php
2
3
namespace PtrTn\Battlerite\Dto\Player;
4
5
/**
6
 * @SuppressWarnings(PHPMD.TooManyFields)
7
 */
8
class Stats
9
{
10
    /**
11
     * @var int|null
12
     */
13
    public $wins;
14
15
    /**
16
     * @var int|null
17
     */
18
    public $losses;
19
20
    /**
21
     * @var int|null
22
     */
23
    public $gradeScore;
24
25
    /**
26
     * @var int|null
27
     */
28
    public $timePlayed;
29
30
    /**
31
     * @var int|null
32
     */
33
    public $ranked2v2Wins;
34
35
    /**
36
     * @var int|null
37
     */
38
    public $ranked2v2Losses;
39
40
    /**
41
     * @var int|null
42
     */
43
    public $ranked3v3Wins;
44
45
    /**
46
     * @var int|null
47
     */
48
    public $ranked3v3Losses;
49
50
    /**
51
     * @var int|null
52
     */
53
    public $unranked2v2Wins;
54
55
    /**
56
     * @var int|null
57
     */
58
    public $unranked2v2Losses;
59
60
    /**
61
     * @var int|null
62
     */
63
    public $unranked3v3Wins;
64
65
    /**
66
     * @var int|null
67
     */
68
    public $unranked3v3Losses;
69
70
    /**
71
     * @var int|null
72
     */
73
    public $brawlWins;
74
75
    /**
76
     * @var int|null
77
     */
78
    public $brawlLosses;
79
80
    /**
81
     * @var int|null
82
     */
83
    public $battlegroundsWins;
84
85
    /**
86
     * @var int|null
87
     */
88
    public $battlegroundsLosses;
89
90
    /**
91
     * @var int|null
92
     */
93
    public $accountXP;
94
95
    /**
96
     * @var int|null
97
     */
98
    public $accountLevel;
99
100
    /**
101
     * @var mixed|null
102
     */
103
    public $twitchAccountLinked;
104
105
    /**
106
     * @var int|null
107
     */
108
    public $vsAIPlayed;
109
110
    /**
111
     * @var int|null
112
     */
113
    public $ratingMean;
114
115
    /**
116
     * @var int|null
117
     */
118
    public $ratingDev;
119
120
    /**
121
     * @var Champions
122
     */
123
    public $champions;
124
125
    /**
126
     * @var Maps
127
     */
128
    public $maps;
129
130 1
    public static function createFromArray(
131
        array $accountStats,
132
        array $championStats,
133
        array $mapStats
134
    ): self {
135 1
        $stats = new self();
136 1
        $stats->wins = $accountStats['Wins'] ?? null;
137 1
        $stats->losses = $accountStats['Losses'] ?? null;
138 1
        $stats->gradeScore = $accountStats['GradeScore'] ?? null;
139 1
        $stats->timePlayed = $accountStats['TimePlayed'] ?? null;
140 1
        $stats->ranked2v2Wins = $accountStats['Ranked2v2Wins'] ?? null;
141 1
        $stats->ranked2v2Losses = $accountStats['Ranked2v2Losses'] ?? null;
142 1
        $stats->ranked3v3Wins = $accountStats['Ranked3v3Wins'] ?? null;
143 1
        $stats->ranked3v3Losses = $accountStats['Ranked3v3Losses'] ?? null;
144 1
        $stats->unranked2v2Wins = $accountStats['Unranked2v2Wins'] ?? null;
145 1
        $stats->unranked2v2Losses = $accountStats['Unranked2v2Losses'] ?? null;
146 1
        $stats->unranked3v3Wins = $accountStats['Unranked3v3Wins'] ?? null;
147 1
        $stats->unranked3v3Losses = $accountStats['Unranked3v3Losses'] ?? null;
148 1
        $stats->brawlWins = $accountStats['BrawlWins'] ?? null;
149 1
        $stats->brawlLosses = $accountStats['BrawlLosses'] ?? null;
150 1
        $stats->battlegroundsWins = $accountStats['BattlegroundsWins'] ?? null;
151 1
        $stats->battlegroundsLosses = $accountStats['BattlegroundsLosses'] ?? null;
152 1
        $stats->accountXP = $accountStats['AccountXP'] ?? null;
153 1
        $stats->accountLevel = $accountStats['AccountLevel'] ?? null;
154 1
        $stats->twitchAccountLinked = $accountStats['TwitchAccountLinked'] ?? null;
155 1
        $stats->vsAIPlayed = $accountStats['VsAIPlayed'] ?? null;
156 1
        $stats->ratingMean = $accountStats['RatingMean'] ?? null;
157 1
        $stats->ratingDev = $accountStats['RatingDev'] ?? null;
158
159 1
        $stats->champions = Champions::createFromArray($championStats);
0 ignored issues
show
Documentation Bug introduced by
It seems like \PtrTn\Battlerite\Dto\Pl...omArray($championStats) of type object<self> is incompatible with the declared type object<PtrTn\Battlerite\Dto\Player\Champions> of property $champions.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
160 1
        $stats->maps = Maps::createFromArray($mapStats);
0 ignored issues
show
Documentation Bug introduced by
It seems like \PtrTn\Battlerite\Dto\Pl...ateFromArray($mapStats) of type object<self> is incompatible with the declared type object<PtrTn\Battlerite\Dto\Player\Maps> of property $maps.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
161
162 1
        return $stats;
163
    }
164
}
165