name = $data['name']; try { $holidayData->date = new DateTimeImmutable($data['date']); } catch (Exception $e) { throw new InvalidDateFormatException('Could not convert date: ' . $data['date']); } return $holidayData; } /** * @return string */ public function getName(): string { return $this->name; } /** * @return DateTimeInterface */ public function getDate(): DateTimeInterface { return $this->date; } }