1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace WSW\SiftScience\Support\Traits\Entities; |
4
|
|
|
|
5
|
|
|
use InvalidArgumentException; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Trait PayPalPaymentMethodTrait |
9
|
|
|
* |
10
|
|
|
* @package WSW\SiftScience\Support\Traits\Entities |
11
|
|
|
* @author Ronaldo Matos Rodrigues <[email protected]> |
12
|
|
|
*/ |
13
|
|
|
trait PayPalPaymentMethodTrait |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* @var string |
17
|
|
|
*/ |
18
|
|
|
private $paypalPayerId; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @var string |
22
|
|
|
*/ |
23
|
|
|
private $paypalPayerEmail; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var string |
27
|
|
|
*/ |
28
|
|
|
private $paypalPayerStatus; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var string |
32
|
|
|
*/ |
33
|
|
|
private $paypalAddressStatus; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @var string |
37
|
|
|
*/ |
38
|
|
|
private $paypalProtectionEligibility; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @var string |
42
|
|
|
*/ |
43
|
|
|
private $paypalPaymentStatus; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @return string |
47
|
|
|
*/ |
48
|
1 |
|
public function getPaypalPayerId() |
49
|
|
|
{ |
50
|
1 |
|
return $this->paypalPayerId; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @param string $paypalPayerId |
55
|
|
|
* |
56
|
|
|
* @return PayPalPaymentMethodTrait |
|
|
|
|
57
|
|
|
*/ |
58
|
1 |
|
public function setPaypalPayerId($paypalPayerId) |
59
|
|
|
{ |
60
|
1 |
|
$this->paypalPayerId = $paypalPayerId; |
61
|
|
|
|
62
|
1 |
|
return $this; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @return string |
67
|
|
|
*/ |
68
|
1 |
|
public function getPaypalPayerEmail() |
69
|
|
|
{ |
70
|
1 |
|
return $this->paypalPayerEmail; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @param string $paypalPayerEmail |
75
|
|
|
* |
76
|
|
|
* @return PayPalPaymentMethodTrait |
|
|
|
|
77
|
|
|
*/ |
78
|
2 |
|
public function setPaypalPayerEmail($paypalPayerEmail) |
79
|
|
|
{ |
80
|
2 |
|
if (!filter_var($paypalPayerEmail, FILTER_VALIDATE_EMAIL)) { |
81
|
1 |
|
throw new InvalidArgumentException('You should inform a valid email'); |
82
|
|
|
} |
83
|
|
|
|
84
|
1 |
|
$this->paypalPayerEmail = $paypalPayerEmail; |
85
|
|
|
|
86
|
1 |
|
return $this; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @return string |
91
|
|
|
*/ |
92
|
1 |
|
public function getPaypalPayerStatus() |
93
|
|
|
{ |
94
|
1 |
|
return $this->paypalPayerStatus; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* @param string $paypalPayerStatus |
99
|
|
|
* |
100
|
|
|
* @return PayPalPaymentMethodTrait |
|
|
|
|
101
|
|
|
*/ |
102
|
1 |
|
public function setPaypalPayerStatus($paypalPayerStatus) |
103
|
|
|
{ |
104
|
1 |
|
$this->paypalPayerStatus = $paypalPayerStatus; |
105
|
|
|
|
106
|
1 |
|
return $this; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* @return string |
111
|
|
|
*/ |
112
|
1 |
|
public function getPaypalAddressStatus() |
113
|
|
|
{ |
114
|
1 |
|
return $this->paypalAddressStatus; |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* @param string $paypalAddressStatus |
119
|
|
|
* |
120
|
|
|
* @return PayPalPaymentMethodTrait |
|
|
|
|
121
|
|
|
*/ |
122
|
1 |
|
public function setPaypalAddressStatus($paypalAddressStatus) |
123
|
|
|
{ |
124
|
1 |
|
$this->paypalAddressStatus = $paypalAddressStatus; |
125
|
|
|
|
126
|
1 |
|
return $this; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* @return string |
131
|
|
|
*/ |
132
|
1 |
|
public function getPaypalProtectionEligibility() |
133
|
|
|
{ |
134
|
1 |
|
return $this->paypalProtectionEligibility; |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* @param string $paypalProtectionEligibility |
139
|
|
|
* |
140
|
|
|
* @return PayPalPaymentMethodTrait |
|
|
|
|
141
|
|
|
*/ |
142
|
1 |
|
public function setPaypalProtectionEligibility($paypalProtectionEligibility) |
143
|
|
|
{ |
144
|
1 |
|
$this->paypalProtectionEligibility = $paypalProtectionEligibility; |
145
|
|
|
|
146
|
1 |
|
return $this; |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* @return string |
151
|
|
|
*/ |
152
|
1 |
|
public function getPaypalPaymentStatus() |
153
|
|
|
{ |
154
|
1 |
|
return $this->paypalPaymentStatus; |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
/** |
158
|
|
|
* @param string $paypalPaymentStatus |
159
|
|
|
* |
160
|
|
|
* @return PayPalPaymentMethodTrait |
|
|
|
|
161
|
|
|
*/ |
162
|
1 |
|
public function setPaypalPaymentStatus($paypalPaymentStatus) |
163
|
|
|
{ |
164
|
1 |
|
$this->paypalPaymentStatus = $paypalPaymentStatus; |
165
|
|
|
|
166
|
1 |
|
return $this; |
167
|
|
|
} |
168
|
|
|
} |
169
|
|
|
|
In PHP traits cannot be used for type-hinting as they do not define a well-defined structure. This is because any class that uses a trait can rename that trait’s methods.
If you would like to return an object that has a guaranteed set of methods, you could create a companion interface that lists these methods explicitly.