Skip to content

Commit 27984b0

Browse files
committed
[PHP] [StepStrategy] Remove other cases implementations rather than the concrete class one
1 parent 647475d commit 27984b0

File tree

3 files changed

+3
-45
lines changed

3 files changed

+3
-45
lines changed

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

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,6 @@ public function code(): int
1515

1616
public function stepEstimatedCompletionMinutes(Step $instance): int
1717
{
18-
$estimation = 0;
19-
20-
switch ($instance->type->code()) {
21-
case StepType::VIDEO_STEP_TYPE:
22-
$estimation = $instance->videoDurationInMinutes;
23-
break;
24-
case StepType::QUIZ_STEP_TYPE:
25-
$estimation = QuizStepType::QUIZ_STEP_QUESTION_DURATION_ESTIMATION_IN_MINUTES * count($instance->quizQuestions);
26-
break;
27-
case StepType::EXERCISE_STEP_TYPE:
28-
$estimation = ExerciseStepType::EXERCISE_STEP_DURATION_ESTIMATION_IN_MINUTES;
29-
break;
30-
}
31-
32-
return $estimation;
18+
return self::EXERCISE_STEP_DURATION_ESTIMATION_IN_MINUTES;
3319
}
3420
}

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

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,6 @@ public function code(): int
2121

2222
public function stepEstimatedCompletionMinutes(Step $instance): int
2323
{
24-
$estimation = 0;
25-
26-
switch ($instance->type->code()) {
27-
case StepType::VIDEO_STEP_TYPE:
28-
$estimation = $instance->videoDurationInMinutes;
29-
break;
30-
case StepType::QUIZ_STEP_TYPE:
31-
$estimation = QuizStepType::QUIZ_STEP_QUESTION_DURATION_ESTIMATION_IN_MINUTES * count($instance->quizQuestions);
32-
break;
33-
case StepType::EXERCISE_STEP_TYPE:
34-
$estimation = ExerciseStepType::EXERCISE_STEP_DURATION_ESTIMATION_IN_MINUTES;
35-
break;
36-
}
37-
38-
return $estimation;
24+
return self::QUIZ_STEP_QUESTION_DURATION_ESTIMATION_IN_MINUTES * count($instance->quizQuestions);
3925
}
4026
}

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

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,6 @@ public function code(): int
2020

2121
public function stepEstimatedCompletionMinutes(Step $instance): int
2222
{
23-
$estimation = 0;
24-
25-
switch ($instance->type->code()) {
26-
case StepType::VIDEO_STEP_TYPE:
27-
$estimation = $instance->videoDurationInMinutes;
28-
break;
29-
case StepType::QUIZ_STEP_TYPE:
30-
$estimation = QuizStepType::QUIZ_STEP_QUESTION_DURATION_ESTIMATION_IN_MINUTES * count($instance->quizQuestions);
31-
break;
32-
case StepType::EXERCISE_STEP_TYPE:
33-
$estimation = ExerciseStepType::EXERCISE_STEP_DURATION_ESTIMATION_IN_MINUTES;
34-
break;
35-
}
36-
37-
return $estimation;
23+
return $instance->videoDurationInMinutes;
3824
}
3925
}

0 commit comments

Comments
 (0)