Skip to content

Commit d61b106

Browse files
committed
[PHP] [StepStrategy] Replace if with switch to make it evident that the only criteria taking into account is the typ
1 parent 6772923 commit d61b106

File tree

1 file changed

+10
-6
lines changed
  • examples/php/php-step_strategy-02_replace_type_code_with_strategy/src

1 file changed

+10
-6
lines changed

examples/php/php-step_strategy-02_replace_type_code_with_strategy/src/Step.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,16 @@ public function estimatedCompletionMinutes(): int
3030
{
3131
$estimation = 0;
3232

33-
if ($this->type === self::VIDEO_STEP_TYPE) {
34-
$estimation = $this->videoDurationInMinutes;
35-
} elseif ($this->type === self::QUIZ_STEP_TYPE) {
36-
$estimation = self::QUIZ_STEP_QUESTION_DURATION_ESTIMATION_IN_MINUTES * count($this->quizQuestions);
37-
} elseif ($this->type === self::EXERCISE_STEP_TYPE) {
38-
$estimation = self::EXERCISE_STEP_DURATION_ESTIMATION_IN_MINUTES;
33+
switch ($this->type) {
34+
case self::VIDEO_STEP_TYPE:
35+
$estimation = $this->videoDurationInMinutes;
36+
break;
37+
case self::QUIZ_STEP_TYPE:
38+
$estimation = self::QUIZ_STEP_QUESTION_DURATION_ESTIMATION_IN_MINUTES * count($this->quizQuestions);
39+
break;
40+
case self::EXERCISE_STEP_TYPE:
41+
$estimation = self::EXERCISE_STEP_DURATION_ESTIMATION_IN_MINUTES;
42+
break;
3943
}
4044

4145
return $estimation;

0 commit comments

Comments
 (0)