@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare( strict_types = 1 ); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace WMDE\Fundraising\Frontend\DonationContext\Domain\Model; |
| 6 | 6 | |
@@ -55,11 +55,11 @@ discard block |
||
| 55 | 55 | * |
| 56 | 56 | * @throws \InvalidArgumentException |
| 57 | 57 | */ |
| 58 | - public function __construct( ?int $id, string $status, ?Donor $donor, DonationPayment $payment, |
|
| 59 | - bool $optsIntoNewsletter, DonationTrackingInfo $trackingInfo, DonationComment $comment = null ) { |
|
| 58 | + public function __construct(? int $id, string $status, ? Donor $donor, DonationPayment $payment, |
|
| 59 | + bool $optsIntoNewsletter, DonationTrackingInfo $trackingInfo, DonationComment $comment = null) { |
|
| 60 | 60 | |
| 61 | 61 | $this->id = $id; |
| 62 | - $this->setStatus( $status ); |
|
| 62 | + $this->setStatus($status); |
|
| 63 | 63 | $this->donor = $donor; |
| 64 | 64 | $this->payment = $payment; |
| 65 | 65 | $this->optsIntoNewsletter = $optsIntoNewsletter; |
@@ -67,15 +67,15 @@ discard block |
||
| 67 | 67 | $this->comment = $comment; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - private function setStatus( string $status ) { |
|
| 71 | - if ( !$this->isValidStatus( $status ) ) { |
|
| 72 | - throw new \InvalidArgumentException( 'Invalid donation status' ); |
|
| 70 | + private function setStatus(string $status) { |
|
| 71 | + if (!$this->isValidStatus($status)) { |
|
| 72 | + throw new \InvalidArgumentException('Invalid donation status'); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | $this->status = $status; |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - private function isValidStatus( string $status ): bool { |
|
| 78 | + private function isValidStatus(string $status): bool { |
|
| 79 | 79 | return in_array( |
| 80 | 80 | $status, |
| 81 | 81 | [ |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | ); |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - public function getId(): ?int { |
|
| 92 | + public function getId(): ? int { |
|
| 93 | 93 | return $this->id; |
| 94 | 94 | } |
| 95 | 95 | |
@@ -97,9 +97,9 @@ discard block |
||
| 97 | 97 | * @param int $id |
| 98 | 98 | * @throws \RuntimeException |
| 99 | 99 | */ |
| 100 | - public function assignId( int $id ) { |
|
| 101 | - if ( $this->id !== null && $this->id !== $id ) { |
|
| 102 | - throw new \RuntimeException( 'Id cannot be changed after initial assignment' ); |
|
| 100 | + public function assignId(int $id) { |
|
| 101 | + if ($this->id !== null && $this->id !== $id) { |
|
| 102 | + throw new \RuntimeException('Id cannot be changed after initial assignment'); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | $this->id = $id; |
@@ -129,20 +129,20 @@ discard block |
||
| 129 | 129 | /** |
| 130 | 130 | * Returns the Donor or null for anonymous donations. |
| 131 | 131 | */ |
| 132 | - public function getDonor(): ?Donor { |
|
| 132 | + public function getDonor(): ? Donor { |
|
| 133 | 133 | return $this->donor; |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | /** |
| 137 | 137 | * Returns the DonationComment or null for when there is none. |
| 138 | 138 | */ |
| 139 | - public function getComment(): ?DonationComment { |
|
| 139 | + public function getComment(): ? DonationComment { |
|
| 140 | 140 | return $this->comment; |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - public function addComment( DonationComment $comment ) { |
|
| 144 | - if ( $this->hasComment() ) { |
|
| 145 | - throw new RuntimeException( 'Can only add a single comment to a donation' ); |
|
| 143 | + public function addComment(DonationComment $comment) { |
|
| 144 | + if ($this->hasComment()) { |
|
| 145 | + throw new RuntimeException('Can only add a single comment to a donation'); |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | $this->comment = $comment; |
@@ -164,12 +164,12 @@ discard block |
||
| 164 | 164 | * @throws RuntimeException |
| 165 | 165 | */ |
| 166 | 166 | public function cancel() { |
| 167 | - if ( $this->getPaymentType() !== PaymentType::DIRECT_DEBIT ) { |
|
| 168 | - throw new RuntimeException( 'Can only cancel direct debit' ); |
|
| 167 | + if ($this->getPaymentType() !== PaymentType::DIRECT_DEBIT) { |
|
| 168 | + throw new RuntimeException('Can only cancel direct debit'); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - if ( !$this->statusIsCancellable() ) { |
|
| 172 | - throw new RuntimeException( 'Can only cancel new donations' ); |
|
| 171 | + if (!$this->statusIsCancellable()) { |
|
| 172 | + throw new RuntimeException('Can only cancel new donations'); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | $this->status = self::STATUS_CANCELLED; |
@@ -179,15 +179,15 @@ discard block |
||
| 179 | 179 | * @throws RuntimeException |
| 180 | 180 | */ |
| 181 | 181 | public function confirmBooked() { |
| 182 | - if ( !$this->hasExternalPayment() ) { |
|
| 183 | - throw new RuntimeException( 'Only external payments can be confirmed as booked' ); |
|
| 182 | + if (!$this->hasExternalPayment()) { |
|
| 183 | + throw new RuntimeException('Only external payments can be confirmed as booked'); |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | - if ( !$this->statusAllowsForBooking() ) { |
|
| 187 | - throw new RuntimeException( 'Only incomplete donations can be confirmed as booked' ); |
|
| 186 | + if (!$this->statusAllowsForBooking()) { |
|
| 187 | + throw new RuntimeException('Only incomplete donations can be confirmed as booked'); |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | - if ( $this->hasComment() && ( $this->needsModeration() || $this->isCancelled() ) ) { |
|
| 190 | + if ($this->hasComment() && ($this->needsModeration() || $this->isCancelled())) { |
|
| 191 | 191 | $this->makeCommentPrivate(); |
| 192 | 192 | } |
| 193 | 193 | |
@@ -222,14 +222,14 @@ discard block |
||
| 222 | 222 | * @param PayPalData $payPalData |
| 223 | 223 | * @throws RuntimeException |
| 224 | 224 | */ |
| 225 | - public function addPayPalData( PayPalData $payPalData ) { |
|
| 225 | + public function addPayPalData(PayPalData $payPalData) { |
|
| 226 | 226 | $paymentMethod = $this->payment->getPaymentMethod(); |
| 227 | 227 | |
| 228 | - if ( !( $paymentMethod instanceof PayPalPayment ) ) { |
|
| 229 | - throw new RuntimeException( 'Cannot set PayPal data on a non PayPal payment' ); |
|
| 228 | + if (!($paymentMethod instanceof PayPalPayment)) { |
|
| 229 | + throw new RuntimeException('Cannot set PayPal data on a non PayPal payment'); |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | - $paymentMethod->addPayPalData( $payPalData ); |
|
| 232 | + $paymentMethod->addPayPalData($payPalData); |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | /** |
@@ -237,14 +237,14 @@ discard block |
||
| 237 | 237 | * |
| 238 | 238 | * @throws RuntimeException |
| 239 | 239 | */ |
| 240 | - public function addCreditCardData( CreditCardTransactionData $creditCardData ) { |
|
| 240 | + public function addCreditCardData(CreditCardTransactionData $creditCardData) { |
|
| 241 | 241 | $paymentMethod = $this->payment->getPaymentMethod(); |
| 242 | 242 | |
| 243 | - if ( !( $paymentMethod instanceof CreditCardPayment ) ) { |
|
| 244 | - throw new RuntimeException( 'Cannot set credit card transaction data on a non credit card payment' ); |
|
| 243 | + if (!($paymentMethod instanceof CreditCardPayment)) { |
|
| 244 | + throw new RuntimeException('Cannot set credit card transaction data on a non credit card payment'); |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | - $paymentMethod->addCreditCardTransactionData( $creditCardData ); |
|
| 247 | + $paymentMethod->addCreditCardTransactionData($creditCardData); |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | private function statusIsCancellable(): bool { |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | public function hasExternalPayment(): bool { |
| 255 | - return in_array( $this->getPaymentType(), [ PaymentType::PAYPAL, PaymentType::CREDIT_CARD ] ); |
|
| 255 | + return in_array($this->getPaymentType(), [PaymentType::PAYPAL, PaymentType::CREDIT_CARD]); |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | private function isIncomplete(): bool { |