Conditions | 3 |
Paths | 4 |
Total Lines | 22 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Tests | 15 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
55 | 1 | public static function createFromArray(array $roster): self |
|
56 | { |
||
57 | 1 | Assert::string($roster['type']); |
|
58 | 1 | Assert::string($roster['id']); |
|
59 | 1 | if (isset($roster['attributes'])) { |
|
60 | 1 | Assert::nullOrString($roster['attributes']['shardId']); |
|
61 | 1 | Assert::nullOrInteger($roster['attributes']['stats']['score']); |
|
62 | 1 | Assert::nullOrString($roster['attributes']['won']); |
|
63 | } |
||
64 | |||
65 | // Todo, this should probably be a boolean in json. |
||
66 | 1 | $won = $roster['attributes']['won'] ? filter_var($roster['attributes']['won'], FILTER_VALIDATE_BOOLEAN) : null; |
|
67 | |||
68 | 1 | return new self( |
|
69 | 1 | $roster['type'], |
|
70 | 1 | $roster['id'], |
|
71 | 1 | $roster['attributes']['shardId'] ?? null, |
|
72 | 1 | $roster['attributes']['stats']['score'] ?? null, |
|
73 | 1 | $won, |
|
74 | 1 | null |
|
75 | ); |
||
76 | } |
||
77 | } |
||
78 |