From dece4ba5168cb60a3288416152c7a472fad61c0a Mon Sep 17 00:00:00 2001 From: louis Date: Sat, 23 Dec 2023 22:17:00 +0100 Subject: [PATCH] Add __toString methods to Entities --- src/Entity/Alias.php | 13 +++++++++++++ src/Entity/Voucher.php | 5 +++++ 2 files changed, 18 insertions(+) diff --git a/src/Entity/Alias.php b/src/Entity/Alias.php index 92bd9e9a..70db939e 100644 --- a/src/Entity/Alias.php +++ b/src/Entity/Alias.php @@ -67,4 +67,17 @@ public function clearSensitiveData(): void $this->user = null; $this->destination = null; } + + public function __toString() + { + if ($this->source === null) { + return ''; + } + + if ($this->random) { + return $this->source . ' -> ' . $this->destination . ' (random)'; + } + + return $this->source . ' -> ' . $this->destination; + } } diff --git a/src/Entity/Voucher.php b/src/Entity/Voucher.php index adabed2e..90975c1b 100644 --- a/src/Entity/Voucher.php +++ b/src/Entity/Voucher.php @@ -75,4 +75,9 @@ public function setInvitedUser(User $invitedUser = null): void { $this->invitedUser = $invitedUser; } + + public function __toString() + { + return $this->code; + } }