1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Z38\SwissPayment\TransactionInformation; |
4
|
|
|
|
5
|
|
|
use DOMDocument; |
6
|
|
|
use InvalidArgumentException; |
7
|
|
|
use LogicException; |
8
|
|
|
use Z38\SwissPayment\ISRParticipant; |
9
|
|
|
use Z38\SwissPayment\Money; |
10
|
|
|
use Z38\SwissPayment\PaymentInformation\PaymentInformation; |
11
|
|
|
use Z38\SwissPayment\RemittanceInformation\ISRReferenceInformation; |
12
|
|
|
use Z38\SwissPayment\RemittanceInformation\RemittanceInformation; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* ISRCreditTransfer contains all the information about a ISR (type 1) transaction. |
16
|
|
|
*/ |
17
|
|
|
class ISRCreditTransfer extends CreditTransfer |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* @var ISRParticipant |
21
|
|
|
*/ |
22
|
|
|
protected $creditorAccount; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* {@inheritdoc} |
26
|
|
|
* |
27
|
|
|
* @param ISRParticipant $creditorAccount ISR participation number of the creditor |
28
|
|
|
* @param string $creditorReference ISR reference number |
29
|
|
|
* |
30
|
|
|
* @throws InvalidArgumentException When the amount is not in EUR or CHF. |
31
|
|
|
*/ |
32
|
3 |
|
public function __construct($instructionId, $endToEndId, Money\Money $amount, ISRParticipant $creditorAccount, $creditorReference) |
33
|
|
|
{ |
34
|
3 |
|
if (!$amount instanceof Money\EUR && !$amount instanceof Money\CHF) { |
35
|
1 |
|
throw new InvalidArgumentException(sprintf( |
36
|
1 |
|
'The amount must be an instance of Z38\SwissPayment\Money\EUR or Z38\SwissPayment\Money\CHF (instance of %s given).', |
37
|
1 |
|
get_class($amount) |
38
|
1 |
|
)); |
39
|
|
|
} |
40
|
|
|
|
41
|
2 |
|
$this->instructionId = (string) $instructionId; |
42
|
2 |
|
$this->endToEndId = (string) $endToEndId; |
43
|
2 |
|
$this->amount = $amount; |
44
|
2 |
|
$this->creditorAccount = $creditorAccount; |
45
|
2 |
|
$this->localInstrument = 'CH01'; |
46
|
|
|
|
47
|
2 |
|
parent::setRemittanceInformation(new ISRReferenceInformation($creditorReference)); |
|
|
|
|
48
|
2 |
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* {@inheritdoc} |
52
|
|
|
*/ |
53
|
1 |
|
public function setRemittanceInformation(RemittanceInformation $remittanceInformation) |
54
|
|
|
{ |
55
|
1 |
|
throw new LogicException('ISR payments are not able to store additional remittance information.'); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* {@inheritdoc} |
60
|
|
|
*/ |
61
|
2 |
|
public function asDom(DOMDocument $doc, PaymentInformation $paymentInformation) |
62
|
|
|
{ |
63
|
2 |
|
$root = $this->buildHeader($doc, $paymentInformation); |
64
|
|
|
|
65
|
2 |
|
$creditorAccount = $doc->createElement('CdtrAcct'); |
66
|
2 |
|
$creditorAccount->appendChild($this->creditorAccount->asDom($doc)); |
67
|
2 |
|
$root->appendChild($creditorAccount); |
68
|
|
|
|
69
|
2 |
|
$this->appendPurpose($doc, $root); |
70
|
|
|
|
71
|
2 |
|
$this->appendRemittanceInformation($doc, $root); |
72
|
|
|
|
73
|
2 |
|
return $root; |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
|
This check looks for a call to a parent method whose name is different than the method from which it is called.
Consider the following code:
The
getFirstName()
method in theSon
calls the wrong method in the parent class.