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