Allow caller to be null

This commit is contained in:
Julien Fastré 2025-06-24 15:02:22 +02:00
parent 0cf922be64
commit df745a1c6a
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB

View File

@ -53,7 +53,7 @@ class CallerHistory implements TrackCreationInterface
private ?ThirdParty $thirdParty = null;
public function __construct(
ThirdParty|Person $caller,
ThirdParty|Person|null $caller,
#[ORM\ManyToOne(targetEntity: Ticket::class)]
#[ORM\JoinColumn(nullable: false)]
private Ticket $ticket,
@ -129,12 +129,11 @@ class CallerHistory implements TrackCreationInterface
*
* This is a private method and should be only called while instance creation
*/
private function setCaller(Person|ThirdParty $caller): void
private function setCaller(Person|ThirdParty|null $caller): void
{
if ($caller instanceof Person) {
$this->setPerson($caller);
} else {
} elseif ($caller instanceof ThirdParty) {
$this->setThirdParty($caller);
}
}
@ -142,7 +141,7 @@ class CallerHistory implements TrackCreationInterface
/**
* Get the caller, which can be either a Person or a ThirdParty.
*/
public function getCaller(): Person|ThirdParty
public function getCaller(): Person|ThirdParty|null
{
return $this->person ?? $this->thirdParty;
}