From ec73d658a742cba630f1ae03ac6160f6c24b52b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20D=C4=9Bdi=C4=8D?= Date: Thu, 28 Sep 2023 15:08:36 +0200 Subject: [PATCH] Pushed common properties from Participant and Instructor to ParticipatingPerson --- app/model/DTO/Instructor/Instructor.php | 33 +-------------- app/model/DTO/Participant/Participant.php | 40 ++++--------------- .../DTO/Participant/ParticipatingPerson.php | 31 ++++++++++++++ 3 files changed, 40 insertions(+), 64 deletions(-) diff --git a/app/model/DTO/Instructor/Instructor.php b/app/model/DTO/Instructor/Instructor.php index 4d14578d8f..4bd28da726 100644 --- a/app/model/DTO/Instructor/Instructor.php +++ b/app/model/DTO/Instructor/Instructor.php @@ -6,27 +6,20 @@ use Model\DTO\Participant\ParticipatingPerson; use Model\Participant\Payment; -use Model\Utils\MoneyFactory; /** - * @property-read int $personId * @property-read int $educationId * @property-read string $educationName * @property-read string $instructorType * @property-read string $scoutExperience * @property-read string $professionalExperience * @property-read string $eventFocus - * @property-read float $payment - * @property-read float $repayment - * @property-read string $onAccount */ class Instructor extends ParticipatingPerson { - private Payment $paymentObj; - public function __construct( int $id, - private int $personId, + int $personId, string $firstName, string $lastName, string|null $nickname = null, @@ -38,14 +31,7 @@ public function __construct( private string $eventFocus, Payment $payment, ) { - parent::__construct($id, $firstName, $lastName, $nickname); - - $this->paymentObj = $payment; - } - - public function getPersonId(): int - { - return $this->personId; + parent::__construct($id, $personId, $firstName, $lastName, $nickname, $payment); } public function getEducationId(): int @@ -77,19 +63,4 @@ public function getEventFocus(): string { return $this->eventFocus; } - - public function getPayment(): float - { - return MoneyFactory::toFloat($this->paymentObj->getPayment()); - } - - public function getRepayment(): float - { - return MoneyFactory::toFloat($this->paymentObj->getRepayment()); - } - - public function getOnAccount(): string - { - return $this->paymentObj->getAccount(); - } } diff --git a/app/model/DTO/Participant/Participant.php b/app/model/DTO/Participant/Participant.php index 0d40dda8ee..ed0e2d3521 100644 --- a/app/model/DTO/Participant/Participant.php +++ b/app/model/DTO/Participant/Participant.php @@ -6,28 +6,24 @@ use Cake\Chronos\Date; use Model\Participant\Payment; -use Model\Utils\MoneyFactory; /** - * @property-read int $personId * @property-read int|null $age + * @property-read Date|null $birthday + * @property-read string $unitRegistrationNumber * @property-read string $street * @property-read string $city * @property-read int $postcode - * @property-read Date|null $birthday - * @property-read string $unitRegistrationNumber - * @property-read float $payment - * @property-read float $repayment - * @property-read string $onAccount + * @property-read string $state + * @property-read string $unit * @property-read int $days + * @property-read string $category */ class Participant extends ParticipatingPerson { - private Payment $paymentObj; - public function __construct( int $id, - private int $personId, + int $personId, string $firstName, string $lastName, string|null $nickName = null, @@ -43,14 +39,7 @@ public function __construct( Payment $payment, private string|null $category = null, ) { - parent::__construct($id, $firstName, $lastName, $nickName); - - $this->paymentObj = $payment; - } - - public function getPersonId(): int - { - return $this->personId; + parent::__construct($id, $personId, $firstName, $lastName, $nickName, $payment); } public function getAge(): int|null @@ -98,21 +87,6 @@ public function getDays(): int return $this->days; } - public function getPayment(): float - { - return MoneyFactory::toFloat($this->paymentObj->getPayment()); - } - - public function getRepayment(): float - { - return MoneyFactory::toFloat($this->paymentObj->getRepayment()); - } - - public function getOnAccount(): string - { - return $this->paymentObj->getAccount(); - } - public function getCategory(): string { return $this->category ?? ''; diff --git a/app/model/DTO/Participant/ParticipatingPerson.php b/app/model/DTO/Participant/ParticipatingPerson.php index 89a689a408..a763eeac55 100644 --- a/app/model/DTO/Participant/ParticipatingPerson.php +++ b/app/model/DTO/Participant/ParticipatingPerson.php @@ -4,25 +4,36 @@ namespace Model\DTO\Participant; +use Model\Participant\Payment; +use Model\Utils\MoneyFactory; use Nette\SmartObject; /** * @property-read int $id + * @property-read int $personId * @property-read string $firstName * @property-read string $lastName * @property-read string $nickName * @property-read string $displayName + * @property-read float $payment + * @property-read float $repayment + * @property-read string $onAccount */ class ParticipatingPerson { use SmartObject; + private Payment $paymentObj; + public function __construct( private int $id, + private int $personId, private string $firstName, private string $lastName, private string|null $nickName = null, + Payment $payment, ) { + $this->paymentObj = $payment; } public function getId(): int @@ -30,6 +41,11 @@ public function getId(): int return $this->id; } + public function getPersonId(): int + { + return $this->personId; + } + public function getFirstName(): string { return $this->firstName; @@ -49,4 +65,19 @@ public function getDisplayName(): string { return $this->lastName . ' ' . $this->firstName . ($this->nickName !== null ? '(' . $this->nickName . ')' : ''); } + + public function getPayment(): float + { + return MoneyFactory::toFloat($this->paymentObj->getPayment()); + } + + public function getRepayment(): float + { + return MoneyFactory::toFloat($this->paymentObj->getRepayment()); + } + + public function getOnAccount(): string + { + return $this->paymentObj->getAccount(); + } }