|
3 | 3 | namespace Z38\SwissPayment\TransactionInformation;
|
4 | 4 |
|
5 | 5 | use DOMDocument;
|
| 6 | +use InvalidArgumentException; |
6 | 7 | use Z38\SwissPayment\BC;
|
7 | 8 | use Z38\SwissPayment\BIC;
|
8 | 9 | use Z38\SwissPayment\FinancialInstitutionInterface;
|
@@ -32,25 +33,23 @@ class BankCreditTransfer extends CreditTransfer
|
32 | 33 | * @param IBAN $creditorIBAN IBAN of the creditor
|
33 | 34 | * @param BC|BIC $creditorAgent BC or BIC of the creditor's financial institution
|
34 | 35 | *
|
35 |
| - * @throws \InvalidArgumentException. |
36 |
| - * An InvalidArgumentException is thrown if amount is not EUR or CHF |
37 |
| - * or if creditorAgent is not BC or BIC |
| 36 | + * @throws \InvalidArgumentException When the amount is not in EUR or CHF or when the creditor agent is not BC or BIC. |
38 | 37 | */
|
39 | 38 | public function __construct($instructionId, $endToEndId, Money\Money $amount, $creditorName, PostalAddressInterface $creditorAddress, IBAN $creditorIBAN, FinancialInstitutionInterface $creditorAgent)
|
40 | 39 | {
|
41 |
| - if (false === $amount instanceof Money\EUR && false === $amount instanceof Money\CHF) { |
42 |
| - throw new \InvalidArgumentException(sprintf( |
43 |
| - 'Amount must be an instance of Z38\SwissPayment\Money\EUR or Z38\SwissPayment\Money\CHF. Instance of %s given.', |
| 40 | + if (!$amount instanceof Money\EUR && !$amount instanceof Money\CHF) { |
| 41 | + throw new InvalidArgumentException(sprintf( |
| 42 | + 'The amount must be an instance of Z38\SwissPayment\Money\EUR or Z38\SwissPayment\Money\CHF (instance of %s given).', |
44 | 43 | get_class($amount)
|
45 | 44 | ));
|
46 | 45 | }
|
47 | 46 |
|
48 |
| - parent::__construct($instructionId, $endToEndId, $amount, $creditorName, $creditorAddress); |
49 |
| - |
50 | 47 | if (!$creditorAgent instanceof BC && !$creditorAgent instanceof BIC) {
|
51 |
| - throw new \InvalidArgumentException('The creditor agent must be an instance of BC or BIC.'); |
| 48 | + throw new InvalidArgumentException('The creditor agent must be an instance of BC or BIC.'); |
52 | 49 | }
|
53 | 50 |
|
| 51 | + parent::__construct($instructionId, $endToEndId, $amount, $creditorName, $creditorAddress); |
| 52 | + |
54 | 53 | $this->creditorIBAN = $creditorIBAN;
|
55 | 54 | $this->creditorAgent = $creditorAgent;
|
56 | 55 | }
|
|
0 commit comments