1 | <?php |
||
9 | final class Customer extends BaseResource implements Emptiable, Serializable |
||
10 | { |
||
11 | use EmptiableTrait; |
||
12 | |||
13 | const INDIVIDUAL = 'f'; |
||
14 | const BUSINESS = 'j'; |
||
15 | |||
16 | /** |
||
17 | * @var string |
||
18 | */ |
||
19 | private $name; |
||
20 | |||
21 | /** |
||
22 | * @var string |
||
23 | */ |
||
24 | private $type; |
||
25 | |||
26 | /** |
||
27 | * @var string |
||
28 | */ |
||
29 | private $taxpayerId; |
||
30 | |||
31 | /** |
||
32 | * @var string |
||
33 | */ |
||
34 | private $email; |
||
35 | |||
36 | /** |
||
37 | * @var Phone |
||
38 | */ |
||
39 | private $phone; |
||
40 | |||
41 | /** |
||
42 | * @var Address |
||
43 | */ |
||
44 | private $address; |
||
45 | |||
46 | /** |
||
47 | * @return Address |
||
48 | */ |
||
49 | public function getAddress() |
||
50 | { |
||
51 | if (is_null($this->address)) { |
||
52 | $this->address = new Address(); |
||
53 | } |
||
54 | |||
55 | return $this->address; |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * @return string |
||
60 | */ |
||
61 | public function getName() |
||
62 | { |
||
63 | return $this->name; |
||
64 | } |
||
65 | |||
66 | /** |
||
67 | * @return string |
||
68 | */ |
||
69 | public function getType() |
||
70 | { |
||
71 | return $this->type; |
||
72 | } |
||
73 | |||
74 | /** |
||
75 | * @return string |
||
76 | */ |
||
77 | public function getTaxpayerId() |
||
78 | { |
||
79 | return $this->taxpayerId; |
||
80 | } |
||
81 | |||
82 | /** |
||
83 | * @return string |
||
84 | */ |
||
85 | public function getEmail() |
||
86 | { |
||
87 | return $this->email; |
||
88 | } |
||
89 | |||
90 | /** |
||
91 | * @return string |
||
92 | */ |
||
93 | public function getPhone() |
||
94 | { |
||
95 | if (is_null($this->phone)) { |
||
96 | $this->phone = new Phone(); |
||
97 | } |
||
98 | |||
99 | return $this->phone->getAreaCode().$this->phone->getNumber(); |
||
100 | } |
||
101 | |||
102 | /** |
||
103 | * @param string $name |
||
104 | */ |
||
105 | public function setName($name) |
||
106 | { |
||
107 | $this->name = substr((string) $name, 0, 50); |
||
108 | |||
109 | return $this; |
||
110 | } |
||
111 | |||
112 | private function setType() |
||
113 | { |
||
114 | if ($this->isIndividual()) { |
||
115 | $this->type = self::INDIVIDUAL; |
||
116 | |||
117 | return $this; |
||
118 | } |
||
119 | |||
120 | $this->type = self::BUSINESS; |
||
121 | |||
122 | return $this; |
||
123 | } |
||
124 | |||
125 | /** |
||
126 | * @param string $taxpayerId |
||
127 | */ |
||
128 | public function setTaxpayerId($taxpayerId) |
||
136 | |||
137 | /** |
||
138 | * @param string $email |
||
139 | */ |
||
140 | public function setEmail($email) |
||
146 | |||
147 | /** |
||
148 | * @param string $areaCode |
||
149 | * @param string $number |
||
150 | */ |
||
151 | public function setPhone($areaCode, $number) |
||
152 | { |
||
153 | $this->phone = new Phone(); |
||
154 | $this->phone |
||
160 | |||
161 | /** |
||
162 | * @param Address $address |
||
163 | */ |
||
164 | public function setAddress(Address $address) |
||
170 | |||
171 | private function isIndividual() |
||
175 | |||
176 | public function serialize() |
||
193 | } |
||
194 |