AbstractAccount   A
last analyzed

Complexity

Total Complexity 22

Size/Duplication

Total Lines 266
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 22
c 0
b 0
f 0
lcom 2
cbo 5
dl 0
loc 266
ccs 57
cts 57
cp 1
rs 10

21 Methods

Rating   Name   Duplication   Size   Complexity  
A getUserEmail() 0 4 1
A setUserEmail() 0 6 1
A getName() 0 4 1
A setName() 0 6 1
A getPhone() 0 4 1
A setPhone() 0 6 1
A getReferrerUserId() 0 4 1
A setReferrerUserId() 0 6 1
A getPaymentMethods() 0 4 1
A addPaymentMethod() 0 6 1
A getBillingAddress() 0 4 1
A setBillingAddress() 0 6 1
A getShippingAddress() 0 4 1
A setShippingAddress() 0 6 1
A getPromotions() 0 4 1
A addPromotion() 0 6 1
A getSocialSignOnType() 0 4 1
A setSocialSignOnType() 0 10 2
A isChangedPassword() 0 4 1
A setChangedPassword() 0 6 1
A __construct() 0 6 1
1
<?php
2
3
namespace WSW\SiftScience\Events;
4
5
use InvalidArgumentException;
6
use WSW\Email\Email;
7
use WSW\SiftScience\Collections\PaymentMethods;
8
use WSW\SiftScience\Collections\Promotions;
9
use WSW\SiftScience\Entities\Address;
10
use WSW\SiftScience\Entities\PaymentMethod;
11
use WSW\SiftScience\Entities\Promotion;
12
use WSW\SiftScience\Support\AllowedValues\SocialSignOnType;
13
use WSW\SiftScience\Support\Formatter;
14
15
/**
16
 * Class AbstractAccount
17
 *
18
 * @package WSW\SiftScience\Events
19
 * @author Ronaldo Matos Rodrigues <[email protected]>
20
 */
21
abstract class AbstractAccount extends BaseEvent
22
{
23
    /**
24
     * @var Email
25
     */
26
    protected $userEmail;
27
28
    /**
29
     * @var string
30
     */
31
    protected $name;
32
33
    /**
34
     * @var string
35
     */
36
    protected $phone;
37
38
    /**
39
     * @var string
40
     */
41
    protected $referrerUserId;
42
43
    /**
44
     * @var PaymentMethods
45
     */
46
    protected $paymentMethods;
47
48
    /**
49
     * @var Address
50
     */
51
    protected $billingAddress;
52
53
    /**
54
     * @var Address
55
     */
56
    protected $shippingAddress;
57
58
    /**
59
     * @var Promotions
60
     */
61
    protected $promotions;
62
63
    /**
64
     * @var string
65
     */
66
    protected $socialSignOnType;
67
68
    /**
69
     * @var bool
70
     */
71
    protected $changedPassword = false;
72
73
    /**
74
     * @param $type
75
     */
76 10
    public function __construct($type)
77
    {
78 10
        $this->type = $type;
79 10
        $this->paymentMethods = new PaymentMethods();
80 10
        $this->promotions = new Promotions();
81 10
    }
82
83
    /**
84
     * @return Email
85
     */
86 6
    public function getUserEmail()
87
    {
88 6
        return $this->userEmail;
89
    }
90
91
    /**
92
     * @param Email $userEmail
93
     *
94
     * @return $this
95
     */
96 1
    public function setUserEmail(Email $userEmail)
97
    {
98 1
        $this->userEmail = $userEmail;
99
100 1
        return $this;
101
    }
102
103
    /**
104
     * @return string
105
     */
106 6
    public function getName()
107
    {
108 6
        return $this->name;
109
    }
110
111
    /**
112
     * @param string $name
113
     *
114
     * @return $this
115
     */
116 1
    public function setName($name)
117
    {
118 1
        $this->name = $name;
119
120 1
        return $this;
121
    }
122
123
    /**
124
     * @return string
125
     */
126 6
    public function getPhone()
127
    {
128 6
        return $this->phone;
129
    }
130
131
    /**
132
     * @param string $phone
133
     *
134
     * @return $this
135
     */
136 1
    public function setPhone($phone)
137
    {
138 1
        $this->phone = Formatter::phone($phone);
139
140 1
        return $this;
141
    }
142
143
    /**
144
     * @return string
145
     */
146 6
    public function getReferrerUserId()
147
    {
148 6
        return $this->referrerUserId;
149
    }
150
151
    /**
152
     * @param string $referrerUserId
153
     *
154
     * @return $this
155
     */
156 1
    public function setReferrerUserId($referrerUserId)
157
    {
158 1
        $this->referrerUserId = $referrerUserId;
159
160 1
        return $this;
161
    }
162
163
    /**
164
     * @return PaymentMethods
165
     */
166 6
    public function getPaymentMethods()
167
    {
168 6
        return $this->paymentMethods;
169
    }
170
171
    /**
172
     * @param PaymentMethod $paymentMethod
173
     *
174
     * @return $this
175
     */
176 1
    public function addPaymentMethod(PaymentMethod $paymentMethod)
177
    {
178 1
        $this->paymentMethods->add($paymentMethod);
179
180 1
        return $this;
181
    }
182
183
    /**
184
     * @return Address
185
     */
186 6
    public function getBillingAddress()
187
    {
188 6
        return $this->billingAddress;
189
    }
190
191
    /**
192
     * @param Address $billingAddress
193
     *
194
     * @return $this
195
     */
196 1
    public function setBillingAddress(Address $billingAddress)
197
    {
198 1
        $this->billingAddress = $billingAddress;
199
200 1
        return $this;
201
    }
202
203
    /**
204
     * @return Address
205
     */
206 6
    public function getShippingAddress()
207
    {
208 6
        return $this->shippingAddress;
209
    }
210
211
    /**
212
     * @param Address $shippingAddress
213
     *
214
     * @return $this
215
     */
216 1
    public function setShippingAddress(Address $shippingAddress)
217
    {
218 1
        $this->shippingAddress = $shippingAddress;
219
220 1
        return $this;
221
    }
222
223
    /**
224
     * @return Promotions
225
     */
226 1
    public function getPromotions()
227
    {
228 1
        return $this->promotions;
229
    }
230
231
    /**
232
     * @param Promotion $promotion
233
     *
234
     * @return $this
235
     */
236 1
    public function addPromotion(Promotion $promotion)
237
    {
238 1
        $this->promotions->add($promotion);
239
240 1
        return $this;
241
    }
242
243
    /**
244
     * @return string
245
     */
246 6
    public function getSocialSignOnType()
247
    {
248 6
        return $this->socialSignOnType;
249
    }
250
251
    /**
252
     * @param string $socialSignOnType
253
     *
254
     * @return $this
255
     */
256 2
    public function setSocialSignOnType($socialSignOnType)
257
    {
258 2
        if (!SocialSignOnType::isValid($socialSignOnType)) {
259 1
            throw new InvalidArgumentException('You should inform a valid social sign on type.');
260
        }
261
262 1
        $this->socialSignOnType = $socialSignOnType;
263
264 1
        return $this;
265
    }
266
267
    /**
268
     * @return bool
269
     */
270 6
    public function isChangedPassword()
271
    {
272 6
        return $this->changedPassword;
273
    }
274
275
    /**
276
     * @param bool $changedPassword
277
     *
278
     * @return $this
279
     */
280 1
    public function setChangedPassword($changedPassword)
281
    {
282 1
        $this->changedPassword = $changedPassword;
283
284 1
        return $this;
285
    }
286
}
287