/** * @param Project $project * @param bool|false $withWorkTime * @return ProjectDTO */ public static function withEntity(Project $project, $withWorkTime = false) { $dto = new ProjectDTO(); $dto->setId($project->getId()); $dto->setDescription($project->getDescription()); $dto->setHourlyRate($project->getHourlyRate()); $dto->setTitle($project->getTitle()); if ($withWorkTime) { foreach ($project->getWorkTimes() as $workTime) { $dto->addWorkTime(WorkTimeDTO::withEntity($workTime)); } } return $dto; }
/** * @param $userId * @param $workTimeId * @return WorkTimeDTO * @throws WorkTimeNotFoundException */ public function findWorkTimeByUserAndId($userId, $workTimeId) { $workTime = $this->workTimeRepository->findWorkTimeByUserAndId($userId, $workTimeId); if ($workTime === null) { throw new WorkTimeNotFoundException(); } return WorkTimeDTO::withEntity($workTime); }