Completed
Pull Request — master (#6)
by Peter
03:53 queued 21s
created

Stats   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 157
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

1 Method

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