Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e7b9e6c

Browse files
ESTE ES UN STEP TEMPORAL
1 parent 1d6a43f commit e7b9e6c

File tree

1 file changed

+25
-19
lines changed

1 file changed

+25
-19
lines changed

‎examples/php/php-divergent_change-01_base/src/Controller/CourseStepsGetController.php‎

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,28 +27,10 @@ public function get(string $courseId): string
2727
if (empty($csv)) {
2828
return '[]';
2929
}
30-
$results = '[';
3130

3231
$csvLines = explode(PHP_EOL, $csv);
3332

34-
$parsedCsv = [];
35-
foreach ($csvLines as $row) {
36-
$row = str_getcsv($row);
37-
38-
[$stepId, $type, $quizTotalQuestions, $videoDuration] = $row;
39-
40-
$isRecognizedStepType = $type !== self::STEP_TYPE_VIDEO && $type !== self::STEP_TYPE_QUIZ;
41-
if ($isRecognizedStepType) {
42-
continue;
43-
}
44-
45-
$parsedCsv[] = [
46-
'stepId' => $stepId,
47-
'type' => $type,
48-
'quizTotalQuestions' => $quizTotalQuestions,
49-
'videoDuration' => $videoDuration,
50-
];
51-
}
33+
$parsedCsv = $this->parseCsv($csvLines);
5234

5335
$results = '[';
5436

@@ -106,4 +88,28 @@ public function get(string $courseId): string
10688

10789
return $results;
10890
}
91+
92+
private function parseCsv(array $csvLines): array
93+
{
94+
$parsedCsv = [];
95+
foreach ($csvLines as $row) {
96+
$row = str_getcsv($row);
97+
98+
[$stepId, $type, $quizTotalQuestions, $videoDuration] = $row;
99+
100+
$isRecognizedStepType = $type !== self::STEP_TYPE_VIDEO && $type !== self::STEP_TYPE_QUIZ;
101+
if ($isRecognizedStepType) {
102+
continue;
103+
}
104+
105+
$parsedCsv[] = [
106+
'stepId' => $stepId,
107+
'type' => $type,
108+
'quizTotalQuestions' => $quizTotalQuestions,
109+
'videoDuration' => $videoDuration,
110+
];
111+
}
112+
113+
return $parsedCsv;
114+
}
109115
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /