getDestination()->getDateFrom(); $dateTo = $assignment->getDestination()->getDateTo(); return (new static($assignment->getId(), static::TYPE_ASSIGNMENT)) ->setDateFrom($dateFrom) ->setDateTo($dateTo) ->setJobProfile($assignment->getJobProfile()->getName()) ->setDateRange(sprintf('%s - %s', $dateFrom->format('d.m.Y'), $dateTo->format('d.m.Y'))) ->setStatus($assignment->getStatus()); ; } public static function fromDisposition(Disposition $disposition): static { $assignment = $disposition->getAssignment(); $dateFrom = $assignment->getDestination()->getDateFrom(); $dateTo = $assignment->getDestination()->getDateTo(); return (new static($assignment->getId(), static::TYPE_DISPOSITION)) ->setDateFrom($dateFrom) ->setDateTo($dateTo) ->setJobProfile($assignment->getJobProfile()->getName()) ->setDateRange(sprintf('%s - %s', $dateFrom->format('d.m.Y'), $dateTo->format('d.m.Y'))) ->setStatus($disposition->getStatus()) ->setTeamerName($disposition->getTeamer()->getFullName()) ->setTeamerUuid($disposition->getTeamer()->getUuid()) ; } public function getAssignmentId(): int { return $this->assignmentId; } public function getType(): ?string { return $this->type; } public function getDateFrom(): ?\DateTimeImmutable { return $this->dateFrom; } public function setDateFrom(?\DateTimeImmutable $dateFrom): static { $this->dateFrom = $dateFrom; return $this; } public function getDateTo(): ?\DateTimeImmutable { return $this->dateTo; } public function setDateTo(?\DateTimeImmutable $dateTo): static { $this->dateTo = $dateTo; return $this; } public function getDateRange(): ?string { return $this->dateRange; } public function setDateRange(?string $dateRange): static { $this->dateRange = $dateRange; return $this; } public function getJobProfile(): ?string { return $this->jobProfile; } public function setJobProfile(?string $jobProfile): static { $this->jobProfile = $jobProfile; return $this; } public function getStatus(): ?string { return $this->status; } public function setStatus(?string $status): static { $this->status = $status; return $this; } public function getTeamerName(): ?string { return $this->teamerName; } public function setTeamerName(?string $teamerName): static { $this->teamerName = $teamerName; return $this; } public function getTeamerUuid(): ?string { return $this->teamerUuid; } public function setTeamerUuid(?string $teamerUuid): static { $this->teamerUuid = $teamerUuid; return $this; } public function getKey(): ?string { return $this->getDateFrom()?->format('Ymd'); } public function getNumberOfDays(): int { if (null === $this->getDateFrom() || null === $this->getDateTo()) { return 1; } return $this->getDateFrom()->diff($this->getDateTo())->days; } }