|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Genkgo\Camt\Camt053\Decoder; |
|
4
|
|
|
|
|
5
|
|
|
use Genkgo\Camt\Decoder\Message as BaseMessageDecoder; |
|
6
|
|
|
use Genkgo\Camt\Camt053\DTO as Camt053DTO; |
|
7
|
|
|
use Genkgo\Camt\DTO; |
|
8
|
|
|
use \SimpleXMLElement; |
|
9
|
|
|
use \DateTimeImmutable; |
|
10
|
|
|
use Genkgo\Camt\Iban; |
|
11
|
|
|
|
|
12
|
|
|
class Message extends BaseMessageDecoder |
|
13
|
|
|
{ |
|
14
|
|
|
/** |
|
15
|
|
|
* @param DTO\Message $message |
|
16
|
|
|
* @param SimpleXMLElement $document |
|
17
|
|
|
*/ |
|
18
|
11 |
|
public function addGroupHeader(DTO\Message $message, SimpleXMLElement $document) |
|
19
|
|
|
{ |
|
20
|
11 |
|
$xmlGroupHeader = $document->BkToCstmrStmt->GrpHdr; |
|
21
|
11 |
|
$groupHeader = new DTO\GroupHeader( |
|
22
|
11 |
|
(string)$xmlGroupHeader->MsgId, |
|
23
|
11 |
|
new DateTimeImmutable((string)$xmlGroupHeader->CreDtTm) |
|
24
|
11 |
|
); |
|
25
|
|
|
|
|
26
|
11 |
|
$message->setGroupHeader($groupHeader); |
|
27
|
11 |
|
} |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @param DTO\Message $message |
|
31
|
|
|
* @param SimpleXMLElement $document |
|
32
|
|
|
*/ |
|
33
|
11 |
|
public function addRecords(DTO\Message $message, SimpleXMLElement $document) |
|
34
|
10 |
|
{ |
|
35
|
11 |
|
$statements = []; |
|
36
|
|
|
|
|
37
|
11 |
|
$xmlStatements = $document->BkToCstmrStmt->Stmt; |
|
38
|
11 |
|
foreach ($xmlStatements as $xmlStatement) { |
|
39
|
11 |
|
$statement = new Camt053DTO\Statement( |
|
40
|
11 |
|
(string) $xmlStatement->Id, |
|
41
|
11 |
|
new DateTimeImmutable((string)$xmlStatement->CreDtTm), |
|
42
|
11 |
|
$this->getAccount($xmlStatement) |
|
43
|
11 |
|
); |
|
44
|
|
|
|
|
45
|
11 |
|
$this->recordDecoder->addBalances($statement, $xmlStatement); |
|
46
|
11 |
|
$this->recordDecoder->addEntries($statement, $xmlStatement); |
|
47
|
|
|
|
|
48
|
11 |
|
$statements[] = $statement; |
|
49
|
11 |
|
} |
|
50
|
|
|
|
|
51
|
11 |
|
$message->setRecords($statements); |
|
52
|
11 |
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @param SimpleXMLElement $xmlRecord |
|
56
|
|
|
* |
|
57
|
|
|
* @return DTO\Account |
|
58
|
|
|
*/ |
|
59
|
11 |
|
protected function getAccount(SimpleXMLElement $xmlRecord) |
|
60
|
|
|
{ |
|
61
|
11 |
|
if (isset($xmlRecord->Acct->Id->IBAN)) { |
|
62
|
9 |
|
return new DTO\IbanAccount(new Iban((string) $xmlRecord->Acct->Id->IBAN)); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
7 |
|
$xmlOtherIdentification = $xmlRecord->Acct->Id->Othr; |
|
66
|
7 |
|
$otherAccount = new DTO\OtherAccount((string) $xmlOtherIdentification->Id); |
|
67
|
|
|
|
|
68
|
7 |
|
if (isset($xmlOtherIdentification->SchmeNm)) { |
|
69
|
|
|
if (isset($xmlOtherIdentification->SchmeNm->Cd)) { |
|
70
|
|
|
$otherAccount->setSchemeName((string) $xmlOtherIdentification->SchmeNm->Cd); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
if (isset($otherIdentification->SchmeNm->Prtry)) { |
|
|
|
|
|
|
74
|
10 |
|
$otherAccount->setSchemeName((string) $xmlOtherIdentification->SchmeNm->Prtry); |
|
75
|
10 |
|
} |
|
76
|
10 |
|
} |
|
77
|
|
|
|
|
78
|
7 |
|
if (isset($xmlOtherIdentification->Issr)) { |
|
79
|
10 |
|
$otherAccount->setIssuer($xmlOtherIdentification->Issr); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
7 |
|
return $otherAccount; |
|
83
|
|
|
} |
|
84
|
|
|
} |
|
85
|
|
|
|
This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.
The variable may have been renamed without also renaming all references.