|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Genkgo\Camt\DTO; |
|
4
|
|
|
|
|
5
|
|
|
use BadMethodCallException; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* Class RemittanceInformation |
|
9
|
|
|
* @package Genkgo\Camt\DTO |
|
10
|
|
|
*/ |
|
11
|
|
|
class RemittanceInformation |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* @var string |
|
15
|
|
|
*/ |
|
16
|
|
|
private $message; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* @var CreditorReferenceInformation |
|
20
|
|
|
*/ |
|
21
|
|
|
private $creditorReferenceInformation; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @var StructuredRemittanceInformation[] |
|
25
|
|
|
*/ |
|
26
|
|
|
private $structuredBlocks = []; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @var UnstructuredRemittanceInformation[] |
|
30
|
|
|
*/ |
|
31
|
|
|
private $unstructuredBlocks = []; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @param $message |
|
35
|
|
|
* @return static |
|
36
|
|
|
*/ |
|
37
|
|
|
public static function fromUnstructured($message) |
|
38
|
|
|
{ |
|
39
|
|
|
$information = new static; |
|
40
|
|
|
$information->message = $message; |
|
41
|
|
|
return $information; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @return CreditorReferenceInformation |
|
46
|
|
|
*/ |
|
47
|
13 |
|
public function getCreditorReferenceInformation() |
|
48
|
|
|
{ |
|
49
|
13 |
|
return $this->creditorReferenceInformation; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @param CreditorReferenceInformation $creditorReferenceInformation |
|
54
|
|
|
*/ |
|
55
|
13 |
|
public function setCreditorReferenceInformation($creditorReferenceInformation) |
|
56
|
|
|
{ |
|
57
|
13 |
|
$this->creditorReferenceInformation = $creditorReferenceInformation; |
|
58
|
13 |
|
$this->message = $creditorReferenceInformation->getRef(); |
|
59
|
13 |
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @deprecated Use getStructuredBlocks method instead |
|
63
|
|
|
* @return string |
|
64
|
|
|
*/ |
|
65
|
11 |
|
public function getMessage() |
|
66
|
|
|
{ |
|
67
|
11 |
|
return $this->message; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* @deprecated Use addStructuredBlock method instead |
|
72
|
|
|
* @param string $message |
|
73
|
|
|
*/ |
|
74
|
10 |
|
public function setMessage($message) |
|
75
|
|
|
{ |
|
76
|
10 |
|
$this->message = $message; |
|
77
|
10 |
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* @param StructuredRemittanceInformation $structuredRemittanceInformation |
|
81
|
|
|
*/ |
|
82
|
13 |
|
public function addStructuredBlock(StructuredRemittanceInformation $structuredRemittanceInformation) |
|
83
|
|
|
{ |
|
84
|
13 |
|
return $this->structuredBlocks[] = $structuredRemittanceInformation; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* @return StructuredRemittanceInformation[] |
|
89
|
|
|
*/ |
|
90
|
1 |
|
public function getStructuredBlocks() |
|
91
|
|
|
{ |
|
92
|
1 |
|
return $this->structuredBlocks; |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
/** |
|
96
|
|
|
* @return StructuredRemittanceInformation |
|
97
|
|
|
*/ |
|
98
|
1 |
|
public function getStructuredBlock() |
|
99
|
|
|
{ |
|
100
|
1 |
|
if(isset($this->structuredBlocks[0])) { |
|
101
|
1 |
|
return $this->structuredBlocks[0]; |
|
102
|
|
|
} else { |
|
103
|
|
|
throw new BadMethodCallException('There are no structured block at all for this remittance information'); |
|
104
|
|
|
} |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* @param UnstructuredRemittanceInformation $unstructuredRemittanceInformation |
|
109
|
|
|
*/ |
|
110
|
10 |
|
public function addUnstructuredBlock(UnstructuredRemittanceInformation $unstructuredRemittanceInformation) |
|
111
|
|
|
{ |
|
112
|
10 |
|
return $this->unstructuredBlocks[] = $unstructuredRemittanceInformation; |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
/** |
|
116
|
|
|
* @return UnstructuredRemittanceInformation[] |
|
117
|
|
|
*/ |
|
118
|
1 |
|
public function getUnstructuredBlocks() |
|
119
|
|
|
{ |
|
120
|
1 |
|
return $this->unstructuredBlocks; |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
/** |
|
124
|
|
|
* @return UnstructuredRemittanceInformation |
|
125
|
|
|
*/ |
|
126
|
1 |
|
public function getUnstructuredBlock() |
|
127
|
|
|
{ |
|
128
|
1 |
|
if(isset($this->unstructuredBlocks[0])) { |
|
129
|
1 |
|
return $this->unstructuredBlocks[0]; |
|
130
|
|
|
} else { |
|
131
|
|
|
throw new BadMethodCallException('There are no unstructured block at all for this remittance information'); |
|
132
|
|
|
} |
|
133
|
|
|
} |
|
134
|
|
|
} |
|
135
|
|
|
|