Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Enable TimeSpan with null end #562

Open
wants to merge 2 commits into
base: 2.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Domain/ValueObject/TimeSpan.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
final class TimeSpan extends Occurrence
{
private DateTime $begin;
private DateTime $end;
private ?DateTime $end;

public function __construct(DateTime $begin, DateTime $end)
public function __construct(DateTime $begin, ?DateTime $end = null)
{
$this->begin = $begin;
$this->end = $end;
}

public static function create(DateTime $begin, DateTime $end): self
public static function create(DateTime $begin, ?DateTime $end = null): self
{
return new static($begin, $end);
}
Expand All @@ -32,7 +32,7 @@ public function getBegin(): DateTime
return $this->begin;
}

public function getEnd(): DateTime
public function getEnd(): ?DateTime
{
return $this->end;
}
Expand Down
4 changes: 3 additions & 1 deletion src/Presentation/Factory/EventFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,9 @@ private function getOccurrenceProperties(Occurrence $occurrence): Generator

if ($occurrence instanceof TimeSpan) {
yield $this->dateTimeFactory->createProperty('DTSTART', $occurrence->getBegin());
yield $this->dateTimeFactory->createProperty('DTEND', $occurrence->getEnd());
if ($occurrence->getEnd() !== null) {
yield $this->dateTimeFactory->createProperty('DTEND', $occurrence->getEnd());
}
}
}

Expand Down
Loading