1 | <?php |
||
11 | class Promocodes |
||
12 | { |
||
13 | /** |
||
14 | * Generated codes will be saved here |
||
15 | * to be validated later. |
||
16 | * |
||
17 | * @var array |
||
18 | */ |
||
19 | private $codes = []; |
||
20 | |||
21 | /** |
||
22 | * Length of code will be calculated from asterisks you have |
||
23 | * set as mask in your config file. |
||
24 | * |
||
25 | * @var int |
||
26 | */ |
||
27 | private $length; |
||
28 | |||
29 | /** |
||
30 | * Promocodes constructor. |
||
31 | */ |
||
32 | public function __construct() |
||
38 | |||
39 | /** |
||
40 | * Generates promocodes as many as you wish. |
||
41 | * |
||
42 | * @param int $amount |
||
43 | * |
||
44 | * @return array |
||
45 | */ |
||
46 | public function output($amount = 1) |
||
62 | |||
63 | /** |
||
64 | * Save promocodes into database |
||
65 | * Successful insert returns generated promocodes |
||
66 | * Fail will return empty collection. |
||
67 | * |
||
68 | * @param int $amount |
||
69 | * @param null $reward |
||
70 | * @param array $data |
||
71 | * @param int|null $expires_in |
||
72 | * @param bool $is_disposable |
||
73 | * |
||
74 | * @return \Illuminate\Support\Collection |
||
75 | */ |
||
76 | public function create($amount = 1, $reward = null, array $data = [], $expires_in = null, $is_disposable = false) |
||
96 | |||
97 | /** |
||
98 | * Save one-time use promocodes into database |
||
99 | * Successful insert returns generated promocodes |
||
100 | * Fail will return empty collection. |
||
101 | * |
||
102 | * @param int $amount |
||
103 | * @param null $reward |
||
104 | * @param array $data |
||
105 | * @param int|null $expires_in |
||
106 | * |
||
107 | * @return \Illuminate\Support\Collection |
||
108 | */ |
||
109 | public function createDisposable($amount = 1, $reward = null, array $data = [], $expires_in = null) |
||
113 | |||
114 | /** |
||
115 | * Check promocode in database if it is valid. |
||
116 | * |
||
117 | * @param string $code |
||
118 | * |
||
119 | * @return bool|\Gabievi\Promocodes\Model\Promocode |
||
120 | * @throws \Gabievi\Promocodes\Exceptions\InvalidPromocodeExceprion |
||
121 | */ |
||
122 | public function check($code) |
||
136 | |||
137 | /** |
||
138 | * Apply promocode to user that it's used from now. |
||
139 | * |
||
140 | * @param string $code |
||
141 | * |
||
142 | * @return bool|\Gabievi\Promocodes\Model\Promocode |
||
143 | * @throws \Gabievi\Promocodes\Exceptions\UnauthenticatedExceprion|\Gabievi\Promocodes\Exceptions\AlreadyUsedExceprion |
||
144 | */ |
||
145 | public function apply($code) |
||
165 | |||
166 | /** |
||
167 | * Expire code as it won't usable anymore. |
||
168 | * |
||
169 | * @param string $code |
||
170 | * @return bool |
||
171 | * @throws \Gabievi\Promocodes\Exceptions\InvalidPromocodeExceprion |
||
172 | */ |
||
173 | public function disable($code) |
||
185 | |||
186 | /** |
||
187 | * Clear all expired and used promotion codes |
||
188 | * that can not be used anymore. |
||
189 | * |
||
190 | * @return void |
||
191 | */ |
||
192 | public function clearRedundant() |
||
201 | |||
202 | /** |
||
203 | * Here will be generated single code using your parameters from config. |
||
204 | * |
||
205 | * @return string |
||
206 | */ |
||
207 | private function generate() |
||
239 | |||
240 | /** |
||
241 | * Generate prefix with separator for promocode. |
||
242 | * |
||
243 | * @return string |
||
244 | */ |
||
245 | private function getPrefix() |
||
251 | |||
252 | /** |
||
253 | * Generate suffix with separator for promocode. |
||
254 | * |
||
255 | * @return string |
||
256 | */ |
||
257 | private function getSuffix() |
||
263 | |||
264 | /** |
||
265 | * Your code will be validated to be unique for one request. |
||
266 | * |
||
267 | * @param $collection |
||
268 | * @param $new |
||
269 | * |
||
270 | * @return bool |
||
271 | */ |
||
272 | private function validate($collection, $new) |
||
276 | |||
277 | /** |
||
278 | * Check if user is trying to apply code again. |
||
279 | * |
||
280 | * @param $promocode |
||
281 | * |
||
282 | * @return bool |
||
283 | */ |
||
284 | private function isSecondUsageAttempt($promocode) { |
||
287 | } |
||
288 |
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.