1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SmartCNAB\Support\Bank; |
4
|
|
|
|
5
|
|
|
use SmartCNAB\Contracts\Support\BankSupportInterface; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Bank base support class. |
9
|
|
|
*/ |
10
|
|
|
abstract class Bank implements BankSupportInterface |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* Channels codes. |
14
|
|
|
* |
15
|
|
|
* @var array |
16
|
|
|
*/ |
17
|
|
|
protected static $billing = []; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Channels codes. |
21
|
|
|
* |
22
|
|
|
* @var array |
23
|
|
|
*/ |
24
|
|
|
protected static $channels = []; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Especies codes. |
28
|
|
|
* |
29
|
|
|
* @var array |
30
|
|
|
*/ |
31
|
|
|
protected static $especies = []; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Billing instruction. |
35
|
|
|
* |
36
|
|
|
* @var array |
37
|
|
|
*/ |
38
|
|
|
protected static $instructions = []; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Motives codes. |
42
|
|
|
* |
43
|
|
|
* @var array |
44
|
|
|
*/ |
45
|
|
|
protected static $motives = []; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Remittance occurrences codes. |
49
|
|
|
* |
50
|
|
|
* @var array |
51
|
|
|
*/ |
52
|
|
|
protected static $remittanceOccurrences = []; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Return occurrences codes. |
56
|
|
|
* |
57
|
|
|
* @var array |
58
|
|
|
*/ |
59
|
|
|
protected static $returnOccurrences = []; |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @return array |
63
|
|
|
*/ |
64
|
|
|
public function billing() |
65
|
|
|
{ |
66
|
|
|
return static::$billing; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Return the payment channels. |
71
|
|
|
* |
72
|
|
|
* @return array |
73
|
|
|
*/ |
74
|
|
|
public function channels() |
75
|
|
|
{ |
76
|
|
|
return static::$channels; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* Return the default state of itau infos. |
81
|
|
|
* |
82
|
|
|
* @return array |
83
|
|
|
*/ |
84
|
|
|
abstract public function defaults(); |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @return array |
88
|
|
|
*/ |
89
|
|
|
public function documentsPrefixes() |
90
|
|
|
{ |
91
|
|
|
return []; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* Return all available especies. |
96
|
|
|
* |
97
|
|
|
* @return array |
98
|
|
|
*/ |
99
|
|
|
public function especies() |
100
|
|
|
{ |
101
|
|
|
return static::$especies; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* Return all available emission. |
106
|
|
|
* |
107
|
|
|
* @return array |
108
|
|
|
*/ |
109
|
|
|
public function emission() |
110
|
|
|
{ |
111
|
|
|
return []; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* Return all available instructions. |
116
|
|
|
* |
117
|
|
|
* @return array |
118
|
|
|
*/ |
119
|
|
|
public function instructions() |
120
|
|
|
{ |
121
|
|
|
return static::$instructions; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* Return all motives codes. |
126
|
|
|
* |
127
|
|
|
* @param int $occurrenceCode |
128
|
|
|
* @return array |
129
|
|
|
*/ |
130
|
|
|
public function motives($occurrenceCode = null) |
131
|
|
|
{ |
132
|
|
|
if ( ! $occurrenceCode) return static::$motives; |
|
|
|
|
133
|
|
|
|
134
|
|
|
$occurrenceCode = str_pad($occurrenceCode, 2, 0, STR_PAD_LEFT); |
135
|
|
|
|
136
|
|
|
return $this->findMotives($occurrenceCode); |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* Return all available postage. |
141
|
|
|
* |
142
|
|
|
* @return array |
143
|
|
|
*/ |
144
|
|
|
public function postage() |
145
|
|
|
{ |
146
|
|
|
return []; |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* @return array |
151
|
|
|
*/ |
152
|
|
|
public function rejectionCodes() |
153
|
|
|
{ |
154
|
|
|
return []; |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
/** |
158
|
|
|
* Return all occurrences available for remittances. |
159
|
|
|
* |
160
|
|
|
* @return array |
161
|
|
|
*/ |
162
|
|
|
public function remittanceOccurrences() |
163
|
|
|
{ |
164
|
|
|
return static::$remittanceOccurrences; |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
/** |
168
|
|
|
* Return all occurrences available for returning. |
169
|
|
|
* |
170
|
|
|
* @return array |
171
|
|
|
*/ |
172
|
|
|
public function returnOccurrences() |
173
|
|
|
{ |
174
|
|
|
return static::$returnOccurrences; |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
/** |
178
|
|
|
* Find for a motive group by occurrenceCode. |
179
|
|
|
* |
180
|
|
|
* @param int $occurrenceCode |
181
|
|
|
* @return array |
182
|
|
|
*/ |
183
|
|
|
protected function findMotives($occurrenceCode) |
184
|
|
|
{ |
185
|
|
|
$motives = array_filter($motives, function ($key) use ($occurrenceCode) { |
|
|
|
|
186
|
|
|
return in_array($occurrenceCode, explode(',', $key)); |
187
|
|
|
}, ARRAY_FILTER_USE_KEY); |
188
|
|
|
|
189
|
|
|
return reset($motives); |
190
|
|
|
} |
191
|
|
|
} |
192
|
|
|
|
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
integer
values, zero is a special case, in particular the following results might be unexpected: