1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Omnipay\BillPay; |
4
|
|
|
|
5
|
|
|
use Omnipay\Common\Helper; |
6
|
|
|
use Symfony\Component\HttpFoundation\ParameterBag; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Class Customer |
10
|
|
|
* |
11
|
|
|
* @author Andreas Lange <[email protected]> |
12
|
|
|
* @copyright 2016, Connox GmbH |
13
|
|
|
* @license MIT |
14
|
|
|
*/ |
15
|
|
|
class Customer |
16
|
|
|
{ |
17
|
|
|
const TYPE_NEW = 'n'; |
18
|
|
|
const TYPE_GUEST = 'g'; |
19
|
|
|
const TYPE_EXISTING = 'e'; |
20
|
|
|
|
21
|
|
|
const GROUP_PRIVATE = 'p'; |
22
|
|
|
const GROUP_BUSINESS = 'b'; |
23
|
|
|
|
24
|
|
|
const LANGUAGE_GERMAN = 'de'; |
25
|
|
|
const LANGUAGE_FRENCH = 'fr'; |
26
|
|
|
const LANGUAGE_ITALIAN = 'it'; |
27
|
|
|
const LANGUAGE_DUTCH = 'nl'; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var ParameterBag |
31
|
|
|
*/ |
32
|
|
|
protected $parameters; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Create a new item with the specified parameters |
36
|
|
|
* |
37
|
|
|
* @param array|null $parameters An array of parameters to set on the new object |
38
|
|
|
*/ |
39
|
49 |
|
public function __construct($parameters = null) |
40
|
|
|
{ |
41
|
49 |
|
$this->initialize($parameters); |
42
|
49 |
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @return string |
46
|
|
|
*/ |
47
|
11 |
|
public function getGroup() |
48
|
|
|
{ |
49
|
11 |
|
return $this->getParameter('group'); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @return string |
54
|
|
|
*/ |
55
|
11 |
|
public function getId() |
56
|
|
|
{ |
57
|
11 |
|
return $this->getParameter('id'); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @return string |
62
|
|
|
*/ |
63
|
11 |
|
public function getLanguage() |
64
|
|
|
{ |
65
|
11 |
|
return $this->getParameter('language'); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @return array |
70
|
|
|
*/ |
71
|
1 |
|
public function getParameters() |
72
|
|
|
{ |
73
|
1 |
|
return $this->parameters->all(); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @return string |
78
|
|
|
*/ |
79
|
11 |
|
public function getType() |
80
|
|
|
{ |
81
|
11 |
|
return $this->getParameter('type'); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Initialize this item with the specified parameters |
86
|
|
|
* |
87
|
|
|
* @param array|null $parameters An array of parameters to set on this object |
88
|
|
|
* |
89
|
|
|
* @return Customer |
90
|
|
|
*/ |
91
|
49 |
|
public function initialize($parameters = null) |
92
|
|
|
{ |
93
|
49 |
|
$this->parameters = new ParameterBag(); |
94
|
49 |
|
$this->setType(self::TYPE_NEW); |
95
|
49 |
|
$this->setGroup(self::GROUP_PRIVATE); |
96
|
|
|
|
97
|
49 |
|
if ($parameters !== null) { |
98
|
37 |
|
Helper::initialize($this, $parameters); |
99
|
37 |
|
} |
100
|
|
|
|
101
|
49 |
|
return $this; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* @param string $group |
106
|
|
|
* |
107
|
|
|
* @return Customer |
108
|
|
|
*/ |
109
|
49 |
|
public function setGroup($group) |
110
|
|
|
{ |
111
|
49 |
|
$this->setParameter('group', $group); |
112
|
|
|
|
113
|
49 |
|
return $this; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* @param string $id |
118
|
|
|
* |
119
|
|
|
* @return Customer |
120
|
|
|
*/ |
121
|
37 |
|
public function setId($id) |
122
|
|
|
{ |
123
|
37 |
|
$this->setParameter('id', $id); |
124
|
|
|
|
125
|
37 |
|
return $this; |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* @param string $language Language as ISO 639-1 code |
130
|
|
|
* |
131
|
|
|
* @return Customer |
132
|
|
|
*/ |
133
|
37 |
|
public function setLanguage($language) |
134
|
|
|
{ |
135
|
37 |
|
$this->setParameter('language', strtolower($language)); |
136
|
|
|
|
137
|
37 |
|
return $this; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* @param string $type |
142
|
|
|
* |
143
|
|
|
* @return Customer |
144
|
|
|
*/ |
145
|
49 |
|
public function setType($type) |
146
|
|
|
{ |
147
|
49 |
|
$this->setParameter('type', $type); |
148
|
|
|
|
149
|
49 |
|
return $this; |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* @param string $key |
154
|
|
|
* |
155
|
|
|
* @return mixed |
156
|
|
|
*/ |
157
|
11 |
|
protected function getParameter($key) |
158
|
|
|
{ |
159
|
11 |
|
return $this->parameters->get($key); |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
/** |
163
|
|
|
* @param string $key |
164
|
|
|
* @param mixed $value |
165
|
|
|
* |
166
|
|
|
* @return Customer |
167
|
|
|
*/ |
168
|
49 |
|
protected function setParameter($key, $value) |
169
|
|
|
{ |
170
|
49 |
|
$this->parameters->set($key, $value); |
171
|
|
|
|
172
|
49 |
|
return $this; |
173
|
|
|
} |
174
|
|
|
} |
175
|
|
|
|