| Conditions | 4 |
| Paths | 8 |
| Total Lines | 25 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 16 |
| CRAP Score | 4 |
| 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 | 1 | if (isset($roster['relationships']['participants'])) { |
|
|
|
|||
| 65 | // Todo, make a reference / detailed dto for paticipants? |
||
| 66 | } |
||
| 67 | |||
| 68 | // Todo, this should probably be a boolean in json. |
||
| 69 | 1 | $won = $roster['attributes']['won'] ? filter_var($roster['attributes']['won'], FILTER_VALIDATE_BOOLEAN) : null; |
|
| 70 | |||
| 71 | 1 | return new self( |
|
| 72 | 1 | $roster['type'], |
|
| 73 | 1 | $roster['id'], |
|
| 74 | 1 | $roster['attributes']['shardId'] ?? null, |
|
| 75 | 1 | $roster['attributes']['stats']['score'] ?? null, |
|
| 76 | 1 | $won, |
|
| 77 | 1 | null |
|
| 78 | ); |
||
| 79 | } |
||
| 80 | } |
||
| 81 |
This check looks for the bodies of
ifstatements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.These
ifbodies can be removed. If you have an empty if but statements in theelsebranch, consider inverting the condition.could be turned into
This is much more concise to read.