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