/** * Обработка полей врача перед занесением в БД для изменения рейтинга и шкалы заполненности профайла * @param Doctor $doctor */ public function addDoctor(Doctor $doctor) { foreach ($this->ratingFields as $field => $bonus) { $method = 'get' . ucfirst($field); if (is_callable(array($doctor, $method))) { $value = $doctor->{$method}(); if (!empty($value)) { $doctor->addRating($bonus); } } } $filledBonus = intval(100 / count($this->filledFields)); // = 5 foreach ($this->filledFields as $field) { if ($field == 'academicDegree' && $doctor->getAcademicDegree() == 'Нет') { $filledBonus = 3 * $filledBonus; $doctor->addFilled($filledBonus); } else { $method = 'get' . ucfirst($field); if (is_callable(array($doctor, $method))) { $value = $doctor->{$method}(); if (!empty($value)) { $doctor->addFilled($filledBonus); } } } } }