1 <?php
2
3 namespace Satabank\IPC;
4
5 /**
6 * Customer details class.
7 * Collect and validate client details
8 */
9 class Customer{
10
11 private $email;
12 private $phone;
13 private $firstName;
14 private $lastName;
15 private $country;
16 private $city;
17 private $zip;
18 private $address;
19
20 /**
21 * Customer Email address
22 * @param string $email
23 * @return Customer
24 */
25 public function setEmail($email){
26 $this->email = $email;
27 return $this;
28 }
29
30 /**
31 * Customer Email address
32 * @return string
33 */
34 public function getEmail(){
35 return $this->email;
36 }
37
38 /**
39 * Customer Phone number
40 * @param string $phone
41 * @return Customer
42 */
43 public function setPhone($phone){
44 $this->phone = $phone;
45 return $this;
46 }
47
48 /**
49 * Customer Phone number
50 * @return string
51 */
52 public function getPhone(){
53 return $this->phone;
54 }
55
56 /**
57 * Customer first name
58 * @param string $firstName
59 * @return Customer
60 */
61 public function setFirstName($firstName){
62 $this->firstName = $firstName;
63 return $this;
64 }
65
66 /**
67 * Customer first name
68 * @return string
69 */
70 public function getFirstName(){
71 return $this->firstName;
72 }
73
74 /**
75 * Customer last name
76 * @param string $lastName
77 * @return Customer
78 */
79 public function setLastName($lastName){
80 $this->lastName = $lastName;
81 return $this;
82 }
83
84 /**
85 * Customer last name
86 * @return string
87 */
88 public function getLastName(){
89 return $this->lastName;
90 }
91
92 /**
93 * Customer country code ISO 3166-1
94 * @param type $country
95 * @return Customer
96 */
97 public function setCountry($country){
98 $this->country = $country;
99 return $this;
100 }
101
102 /**
103 * Customer country code ISO 3166-1
104 * @return string
105 */
106 public function getCountry(){
107 return $this->country;
108 }
109
110 /**
111 * Customer city
112 * @param string $city
113 * @return Customer
114 */
115 public function setCity($city){
116 $this->city = $city;
117 return $this;
118 }
119
120 /**
121 * Customer city
122 * @return string
123 */
124 public function getCity(){
125 return $this->city;
126 }
127
128 /**
129 * Customer ZIP code
130 * @param string $zip
131 * @return Customer
132 */
133 public function setZip($zip){
134 $this->zip = $zip;
135 return $this;
136 }
137
138 /**
139 * Customer ZIP code
140 * @return string
141 */
142 public function getZip(){
143 return $this->zip;
144 }
145
146 /**
147 * Customer address
148 * @param string $address
149 * @return Customer
150 */
151 public function setAddress($address){
152 $this->address = $address;
153 return $this;
154 }
155
156 /**
157 * Customer address
158 * @return string
159 */
160 public function getAddress(){
161 return $this->address;
162 }
163
164 /**
165 * Validate all set customer details
166 * @return boolean
167 * @throws IPC_Exception
168 */
169 public function validate(){
170 if($this->getEmail() == null || !Helper::isValidEmail($this->getEmail())){
171 throw new IPC_Exception('Invalid Email');
172 }
173 return true;
174 }
175
176 }
177