id; } /** * @return \DateTime */ public function getBegin() { return $this->begin; } /** * @param \DateTime $begin * @return Timesheet */ public function setBegin($begin) { $this->begin = $begin; return $this; } /** * @return \DateTime */ public function getEnd() { return $this->end; } /** * @param \DateTime $end * @return Timesheet */ public function setEnd($end) { $this->end = $end; if (null === $end) { $this->duration = 0; } return $this; } /** * Set duration * * @param int $duration * @return Timesheet */ public function setDuration($duration) { $this->duration = $duration; return $this; } /** * Get duration * Do not rely on the results of this method for active records. * * @return int */ public function getDuration() { return $this->duration; } /** * Set user * * @param User $user * @return Timesheet */ public function setUser(User $user) { $this->user = $user; return $this; } /** * Get user * * @return User */ public function getUser() { return $this->user; } /** * Set activity * * @param Activity $activity * @return Timesheet */ public function setActivity($activity) { $this->activity = $activity; return $this; } /** * Get Activity * * @return Activity */ public function getActivity() { return $this->activity; } /** * Set description * * @param string $description * @return Timesheet */ public function setDescription($description) { $this->description = $description; return $this; } /** * Get description * * @return string */ public function getDescription() { return $this->description; } /** * Set rate * * @param float $rate * @return Timesheet */ public function setRate($rate) { $this->rate = $rate; return $this; } /** * Get rate * * @return float */ public function getRate() { return $this->rate; } /** * @param ExecutionContextInterface $context * @param mixed $payload * * @Assert\Callback */ public function validate(ExecutionContextInterface $context, $payload) { if (null !== $this->getEnd() && $this->getEnd()->getTimestamp() < $this->getBegin()->getTimestamp()) { $context->buildViolation('End date must not be earlier then start date.') ->atPath('end') ->setTranslationDomain('validators') ->addViolation(); } } }