Имеется только часть кода приложения предназначенного для планирования, нужно его как-то улучшить. В задании говорится что хорошо бы сделать еще один метод (makeDay) который будет рекурсивно вызывать сам себя ???
<?php
private function _getProgramWeeksByChildProgram($childProgram)
{
$weeks = array();
$child = $childProgram->getChild(); //new child
$program = $childProgram->getProgram(); //child program
$programdays = $program->getDays(); //child programs day
for ($i=0; $i<count($programdays); $i++) {
$programday = $programdays[$i];
if ($programday->isVisable()) {
$day = new stdClass();
$day->id = $programday->getId();
$day->date = $programday->getDate();
$day->name = $programday->getName();
$day->date = $programday->getDate();
$day->description = $programday->getDescription();
$day->checkable = $programday->isCheckable();
$day->ageGroup = $programday->getAgeGroup();
$day->checked = $this->_isCheckedDay($programday, $child);
// has other age group ?
if (isset($programdays[$i+1])) {
$nextProgramDay = $programdays[$i+1];
if (is_object($nextProgramDay) &&
$nextProgramDay->getDate() == $programday->getDate()) {
$secondDay = new stdClass();
$secondDay->id = $nextProgramDay->getId();
$secondDay->date = $nextProgramDay->getDate();
$secondDay->name = $nextProgramDay->getName();
$secondDay->date = $nextProgramDay->getDate();
$secondDay->description = $nextProgramDay->getDescription();
$secondDay->checkable = $nextProgramDay->isCheckable();
$secondDay->checked = $this->_isCheckedDay($nextProgramDay, $child);
$secondDay->ageGroup = $nextProgramDay->getAgeGroup();
$day->secondAgeGroup = $secondDay;
$i++;
}
}
$weeks[$programday->getWeekNr()][] = $day;
}
}
return $weeks;
}