12 private $componentName;
24 return new self($componentName);
33 $this->componentName = $componentName;
45 switch ($this->componentName)
48 $this->component = $this->getStandardComponent($properties);
51 $this->component = $this->getDaylightComponent($properties);
54 $this->component = $this->getCalendarComponent($properties, $subComponents);
57 $this->component = $this->getEventComponent($properties, $subComponents);
60 $this->component = $this->getTimezoneComponent($properties, $subComponents);
65 $this->addMessageLog();
76 return $this->component;
87 ->setTzOffsetFrom($properties[
'tzoffsetfrom'] ??
null)
88 ->setDtStart($properties[
'dtstart'] ??
null);
95 private function getDaylightComponent(?array $properties): DaylightObservance
98 ->setTzOffsetTo($properties[
'tzoffsetto'] ??
null)
99 ->setTzOffsetFrom($properties[
'tzoffsetfrom'] ??
null)
100 ->setDtStart($properties[
'dtstart'] ??
null);
108 private function getCalendarComponent($properties, $subComponents): Calendar
111 $name = isset($properties[
'name']) ? $properties[
'name']->getValue() :
'Outer Calendar';
113 ->setMethod($properties[
'method'] ??
null)
114 ->setProdId($properties[
'prodid'] ??
null)
115 ->setCalScale($properties[
'calscale'] ??
null)
116 ->setVersion($properties[
'version'] ??
null)
117 ->setSubComponents($subComponents);
127 private function getEventComponent($properties, $subComponents): Event
129 if (empty($properties[
'uid']))
131 throw new IcalParserException(
"event identifier is not passed");
134 ->setStart($properties[
'dtstart'] ??
null)
135 ->setEnd($properties[
'dtend'] ??
null)
136 ->setDescription($properties[
'description'] ??
null)
137 ->setSummary($properties[
'summary'] ??
null)
138 ->setSequence($properties[
'sequence'] ??
null)
139 ->setCreated($properties[
'created'] ??
null)
140 ->setDTStamp($properties[
'dtstamp'] ??
null)
141 ->setLocation($properties[
'location'] ??
null)
142 ->setUrl($properties[
'url'] ??
null)
143 ->setRRule($properties[
'rrule'] ??
null)
144 ->setTransparent($properties[
'transp'] ??
null)
145 ->setCategories($properties[
'categories'] ??
null)
146 ->setOrganizer($properties[
'organizer'] ??
null)
147 ->setAttendees($properties[
'attendee'] ??
null)
148 ->setModified($properties[
'last-modified'] ??
null)
149 ->setStatus($properties[
'status'] ??
null)
150 ->setRecurrenceId($properties[
'recurrence-id'] ??
null)
151 ->setAttachment($properties[
'attach'] ??
null);
159 private function getTimezoneComponent($properties, $subComponents): Timezone
162 ->setTimezoneId($properties[
'tzid'] ??
null)
163 ->setTimezoneUrl($properties[
'tzurl'] ??
null)
164 ->setSubComponents($subComponents);
170 private function addMessageLog(): void
172 AddMessage2Log(
"Component not found: {$this->componentName}",
"calendar", 2);