| Conditions | 3 |
| Paths | 3 |
| Total Lines | 15 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 25 | 7 | public static function parseArray(array $serialized, string $cpf = null): ChallengeInterface |
|
| 26 | { |
||
| 27 | 7 | if (!array_key_exists('challenge', $serialized)) { |
|
| 28 | 1 | throw new \RuntimeException(); |
|
| 29 | } |
||
| 30 | 6 | if (!array_key_exists('attempts_left', $serialized)) { |
|
| 31 | 1 | throw new \RuntimeException(); |
|
| 32 | } |
||
| 33 | |||
| 34 | 5 | $challengeName = $serialized['challenge']; |
|
| 35 | 5 | $attemptsLeft = $serialized['attempts_left']; |
|
| 36 | 5 | $cpf = $cpf ?? $serialized['cpf'] ?? null; |
|
| 37 | 5 | $choices = $serialized['choices'] ?? []; |
|
| 38 | |||
| 39 | 5 | return ChallengeFactory::create($challengeName, $attemptsLeft, $cpf, $choices); |
|
|
|
|||
| 40 | } |
||
| 42 |