Skip to content

Commit 40ed8ac

Browse files
committed
fix: check if content is null in date property
- return null in helper-functions, if content is null: hasTime, getEnd - throw HandlingException::class, if getStart is called on empty content
1 parent f1e0af9 commit 40ed8ac

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/Entities/Properties/Date.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ public function isRange(): bool
132132
*/
133133
public function getStart(): DateTime
134134
{
135+
if ($this->getContent() === null) {
136+
throw new HandlingException('Invalid content: The content of the Date Property is null.');
137+
}
135138
return $this->getContent()->getStart();
136139
}
137140

@@ -140,6 +143,9 @@ public function getStart(): DateTime
140143
*/
141144
public function getEnd(): ?DateTime
142145
{
146+
if ($this->getContent() === null) {
147+
return null;
148+
}
143149
return $this->getContent()->getEnd();
144150
}
145151

@@ -148,6 +154,9 @@ public function getEnd(): ?DateTime
148154
*/
149155
public function hasTime(): bool
150156
{
157+
if ($this->getContent() === null) {
158+
return false;
159+
}
151160
return $this->getContent()->hasTime();
152161
}
153162
}

0 commit comments

Comments
 (0)