File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
examples/php/php-step_strategy-02_replace_type_code_with_strategy/src Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -9,8 +9,12 @@ final class Step
99 private const EXERCISE_STEP_DURATION_ESTIMATION_IN_MINUTES = 30 ;
1010 private const QUIZ_STEP_QUESTION_DURATION_ESTIMATION_IN_MINUTES = 3 ;
1111
12+ private const VIDEO_STEP_TYPE = 0 ;
13+ private const QUIZ_STEP_TYPE = 1 ;
14+ private const EXERCISE_STEP_TYPE = 2 ;
15+
1216 private string $ title ;
13- private int $ type ; // 0: Video, 1: Quizz, 2: Exercise
17+ private int $ type ;
1418 private ?int $ videoDurationInMinutes ;
1519 private ?array $ quizQuestions ;
1620
@@ -26,11 +30,11 @@ public function estimatedCompletionMinutes(): int
2630 {
2731 $ estimation = 0 ;
2832
29- if ($ this ->type === 0 ) { // Video
33+ if ($ this ->type === self :: VIDEO_STEP_TYPE ) {
3034 $ estimation = $ this ->videoDurationInMinutes ;
31- } elseif ($ this ->type === 1 ) { // Quizz
35+ } elseif ($ this ->type === self :: QUIZ_STEP_TYPE ) {
3236 $ estimation = self ::QUIZ_STEP_QUESTION_DURATION_ESTIMATION_IN_MINUTES * count ($ this ->quizQuestions );
33- } elseif ($ this ->type === 2 ) { // Exercise
37+ } elseif ($ this ->type === self :: EXERCISE_STEP_TYPE ) {
3438 $ estimation = self ::EXERCISE_STEP_DURATION_ESTIMATION_IN_MINUTES ;
3539 }
3640
You can’t perform that action at this time.
0 commit comments