1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Genkgo\Camt\Camt052\Decoder; |
4
|
|
|
|
5
|
|
|
use Genkgo\Camt\Decoder\Message as BaseMessageDecoder; |
6
|
|
|
use Genkgo\Camt\DTO; |
7
|
|
|
use Genkgo\Camt\Camt052\DTO as Camt052DTO; |
8
|
|
|
use \SimpleXMLElement; |
9
|
|
|
use \DateTimeImmutable; |
10
|
|
|
use Genkgo\Camt\Iban; |
11
|
|
|
|
12
|
|
|
abstract class Message extends BaseMessageDecoder |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* @param DTO\Message $message |
16
|
|
|
* @param SimpleXMLElement $document |
17
|
|
|
*/ |
18
|
8 |
|
public function addRecords(DTO\Message $message, SimpleXMLElement $document) |
19
|
|
|
{ |
20
|
8 |
|
$reports = []; |
21
|
|
|
|
22
|
8 |
|
$xmlReports = $this->getRootElement($document)->Rpt; |
|
|
|
|
23
|
8 |
|
foreach ($xmlReports as $xmlReport) { |
24
|
8 |
|
$report = new Camt052DTO\Report( |
25
|
8 |
|
(string) $xmlReport->Id, |
26
|
8 |
|
new DateTimeImmutable((string)$xmlReport->CreDtTm), |
27
|
8 |
|
$this->getAccount($xmlReport) |
|
|
|
|
28
|
8 |
|
); |
29
|
|
|
|
30
|
8 |
|
if (isset($xmlReport->RptPgntn)) { |
31
|
3 |
|
$report->setPagination(new DTO\Pagination( |
32
|
3 |
|
(string) $xmlReport->RptPgntn->PgNb, |
33
|
3 |
|
('true' === (string) $xmlReport->RptPgntn->LastPgInd) ? true : false |
34
|
3 |
|
)); |
35
|
3 |
|
} |
36
|
|
|
|
37
|
8 |
|
if (isset($xmlReport->AddtlRptInf)) { |
38
|
7 |
|
$report->setAdditionalInformation((string) $xmlReport->AddtlRptInf); |
39
|
7 |
|
} |
40
|
|
|
|
41
|
8 |
|
$this->addCommonRecordInformation($report, $xmlReport); |
42
|
8 |
|
$this->recordDecoder->addBalances($report, $xmlReport); |
43
|
8 |
|
$this->recordDecoder->addEntries($report, $xmlReport); |
44
|
|
|
|
45
|
8 |
|
$reports[] = $report; |
46
|
8 |
|
} |
47
|
|
|
|
48
|
8 |
|
$message->setRecords($reports); |
49
|
8 |
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @param SimpleXMLElement $xmlRecord |
53
|
|
|
* |
54
|
|
|
* @return DTO\Account |
55
|
|
|
*/ |
56
|
8 |
|
protected function getAccount(SimpleXMLElement $xmlRecord) |
57
|
|
|
{ |
58
|
8 |
|
if (isset($xmlRecord->Acct->Id->IBAN)) { |
59
|
3 |
|
return new DTO\IbanAccount(new Iban((string) $xmlRecord->Acct->Id->IBAN)); |
60
|
|
|
} |
61
|
|
|
|
62
|
8 |
|
if (isset($xmlRecord->Acct->Id->BBAN)) { |
63
|
|
|
return new DTO\BBANAccount((string) $xmlRecord->Acct->Id->BBAN); |
64
|
|
|
} |
65
|
|
|
|
66
|
8 |
|
if (isset($xmlRecord->Acct->Id->UPIC)) { |
67
|
|
|
return new DTO\UPICAccount((string) $xmlRecord->Acct->Id->UPIC); |
68
|
7 |
|
} |
69
|
|
|
|
70
|
8 |
|
if (isset($xmlRecord->Acct->Id->PrtryAcct)) { |
71
|
8 |
|
return new DTO\ProprietaryAccount((string) $xmlRecord->Acct->Id->PrtryAcct->Id); |
72
|
7 |
|
} |
73
|
|
|
|
74
|
7 |
|
if (isset($xmlRecord->Acct->Id->Othr)) { |
75
|
7 |
|
$xmlOtherIdentification = $xmlRecord->Acct->Id->Othr; |
76
|
7 |
|
$otherAccount = new DTO\OtherAccount((string) $xmlOtherIdentification->Id); |
77
|
|
|
|
78
|
7 |
|
if (isset($xmlOtherIdentification->SchmeNm)) { |
79
|
|
|
if (isset($xmlOtherIdentification->SchmeNm->Cd)) { |
80
|
7 |
|
$otherAccount->setSchemeName((string) $xmlOtherIdentification->SchmeNm->Cd); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
if (isset($xmlOtherIdentification->SchmeNm->Prtry)) { |
84
|
|
|
$otherAccount->setSchemeName((string) $xmlOtherIdentification->SchmeNm->Prtry); |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|
88
|
7 |
|
if (isset($xmlOtherIdentification->Issr)) { |
89
|
|
|
$otherAccount->setIssuer($xmlOtherIdentification->Issr); |
90
|
|
|
} |
91
|
|
|
|
92
|
7 |
|
return $otherAccount; |
93
|
|
|
} |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
|
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.
If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.