| Conditions | 6 |
| Paths | 6 |
| Total Lines | 19 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 6 |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | 11 | public static function create( |
|
| 16 | string $challengeName, |
||
| 17 | int $attemptsLeft, |
||
| 18 | string $cpf, |
||
| 19 | array $choices = null |
||
| 20 | ): ChallengeInterface { |
||
| 21 | switch ($challengeName) { |
||
| 22 | 11 | case SelectMotherInitialsChallenge::CHALLENGE_NAME: |
|
| 23 | 3 | return new SelectMotherInitialsChallenge($attemptsLeft, $cpf, $choices ?? []); |
|
| 24 | 9 | case TypeBirthdayChallenge::CHALLENGE_NAME: |
|
|
|
|||
| 25 | 1 | return new TypeBirthdayChallenge($attemptsLeft, $cpf); |
|
| 26 | 8 | case TypeMotherInitialsChallenge::CHALLENGE_NAME: |
|
| 27 | 4 | return new TypeMotherInitialsChallenge($attemptsLeft, $cpf); |
|
| 28 | 4 | case TypePostalCodeChallenge::CHALLENGE_NAME: |
|
| 29 | 1 | return new TypePostalCodeChallenge($attemptsLeft, $cpf); |
|
| 30 | 3 | case TypeVoterRegistrationChallenge::CHALLENGE_NAME: |
|
| 31 | 2 | return new TypeVoterRegistrationChallenge($attemptsLeft, $cpf); |
|
| 32 | default: |
||
| 33 | 1 | throw new \InvalidArgumentException("Unsupported challenge '{$challengeName}'"); |
|
| 34 | } |
||
| 37 |
As per the PSR-2 coding standard, case statements should not be wrapped in curly braces. There is no need for braces, since each case is terminated by the next
break.There is also the option to use a semicolon instead of a colon, this is discouraged because many programmers do not even know it works and the colon is universal between programming languages.
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.