Skip to content

Commit e97298c

Browse files
committed
[PHP] [StepStrategy] Set initial code in its own folder in order to allow other refactoring approaches in subsequent folders linking to them
1 parent 4d1257e commit e97298c

File tree

5 files changed

+23
-106
lines changed

5 files changed

+23
-106
lines changed

examples/php/php-step_strategy-01_base/src/ExerciseStepType.php

Lines changed: 0 additions & 20 deletions
This file was deleted.

examples/php/php-step_strategy-01_base/src/QuizStepType.php

Lines changed: 0 additions & 27 deletions
This file was deleted.

examples/php/php-step_strategy-01_base/src/Step.php

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,34 @@
66

77
final class Step
88
{
9-
private string $title;
10-
private StepType $type;
9+
private const EXERCISE_STEP_DURATION_ESTIMATION_IN_MINUTES = 30;
10+
private const QUIZ_STEP_QUESTION_DURATION_ESTIMATION_IN_MINUTES = 3;
1111

12-
public function __construct(string $title, int $typeCode, ?int $videoDurationInMinutes, ?array $quizQuestions)
12+
private string $title;
13+
private int $type; // 0: Video, 1: Quizz, 2: Exercise
14+
private ?int $videoDurationInMinutes;
15+
private ?array $quizQuestions;
16+
17+
public function __construct(string $title, int $type, ?int $videoDurationInMinutes, ?array $quizQuestions)
1318
{
14-
$this->title = $title;
15-
$this->type = StepType::fromPrimitive($typeCode, $videoDurationInMinutes, $quizQuestions);
19+
$this->title = $title;
20+
$this->type = $type;
21+
$this->videoDurationInMinutes = $videoDurationInMinutes;
22+
$this->quizQuestions = $quizQuestions;
1623
}
1724

1825
public function estimatedCompletionMinutes(): int
1926
{
20-
return $this->type->estimatedCompletionMinutes();
27+
$estimation = 0;
28+
29+
if ($this->type === 0) { // Video
30+
$estimation = $this->videoDurationInMinutes;
31+
} elseif ($this->type === 1) { // Quizz
32+
$estimation = self::QUIZ_STEP_QUESTION_DURATION_ESTIMATION_IN_MINUTES * count($this->quizQuestions);
33+
} elseif ($this->type === 2) { // Exercise
34+
$estimation = self::EXERCISE_STEP_DURATION_ESTIMATION_IN_MINUTES;
35+
}
36+
37+
return $estimation;
2138
}
2239
}

examples/php/php-step_strategy-01_base/src/StepType.php

Lines changed: 0 additions & 28 deletions
This file was deleted.

examples/php/php-step_strategy-01_base/src/VideoStepType.php

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)