Complex classes like Give_Payment often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Give_Payment, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
24 | final class Give_Payment { |
||
25 | |||
26 | /** |
||
27 | * The Payment ID |
||
28 | * |
||
29 | * @since 1.5 |
||
30 | * |
||
31 | * @var integer |
||
32 | */ |
||
33 | public $ID = 0; |
||
34 | protected $_ID = 0; |
||
35 | |||
36 | /** |
||
37 | * Identify if the payment is a new one or existing |
||
38 | * |
||
39 | * @since 1.5 |
||
40 | * @access protected |
||
41 | * |
||
42 | * @var boolean |
||
43 | */ |
||
44 | protected $new = false; |
||
45 | |||
46 | /** |
||
47 | * The Payment number (for use with sequential payments) |
||
48 | * |
||
49 | * @since 1.5 |
||
50 | * @access protected |
||
51 | * |
||
52 | * @var string |
||
53 | */ |
||
54 | protected $number = ''; |
||
55 | |||
56 | /** |
||
57 | * The Gateway mode the payment was made in |
||
58 | * |
||
59 | * @since 1.5 |
||
60 | * @access protected |
||
61 | * |
||
62 | * @var string |
||
63 | */ |
||
64 | protected $mode = 'live'; |
||
65 | |||
66 | /** |
||
67 | * The Unique Payment Key |
||
68 | * |
||
69 | * @since 1.5 |
||
70 | * @access protected |
||
71 | * |
||
72 | * @var string |
||
73 | */ |
||
74 | protected $key = ''; |
||
75 | |||
76 | /** |
||
77 | * The Donation Form Title |
||
78 | * |
||
79 | * @since 1.5 |
||
80 | * @access protected |
||
81 | * |
||
82 | * @var string |
||
83 | */ |
||
84 | protected $form_title = 0; |
||
85 | |||
86 | /** |
||
87 | * The Donation Form ID |
||
88 | * |
||
89 | * @since 1.5 |
||
90 | * @access protected |
||
91 | * |
||
92 | * @var string |
||
93 | */ |
||
94 | protected $form_id = 0; |
||
95 | |||
96 | /** |
||
97 | * The Donation Form Price ID |
||
98 | * |
||
99 | * @since 1.5 |
||
100 | * @access protected |
||
101 | * |
||
102 | * @var string |
||
103 | */ |
||
104 | protected $price_id = 0; |
||
105 | |||
106 | /** |
||
107 | * The total amount the payment is for |
||
108 | * Includes donation amount and fees |
||
109 | * |
||
110 | * @since 1.5 |
||
111 | * @access protected |
||
112 | * |
||
113 | * @var float |
||
114 | */ |
||
115 | protected $total = 0.00; |
||
116 | |||
117 | /** |
||
118 | * The Subtotal fo the payment before fees |
||
119 | * |
||
120 | * @since 1.5 |
||
121 | * @access protected |
||
122 | * |
||
123 | * @var float |
||
124 | */ |
||
125 | protected $subtotal = 0; |
||
126 | |||
127 | /** |
||
128 | * Array of global fees for this payment |
||
129 | * |
||
130 | * @since 1.5 |
||
131 | * @access protected |
||
132 | * |
||
133 | * @var array |
||
134 | */ |
||
135 | protected $fees = array(); |
||
136 | |||
137 | /** |
||
138 | * The sum of the fee amounts |
||
139 | * |
||
140 | * @since 1.5 |
||
141 | * @access protected |
||
142 | * |
||
143 | * @var float |
||
144 | */ |
||
145 | protected $fees_total = 0; |
||
146 | |||
147 | /** |
||
148 | * The date the payment was created |
||
149 | * |
||
150 | * @since 1.5 |
||
151 | * @access protected |
||
152 | * |
||
153 | * @var string |
||
154 | */ |
||
155 | protected $date = ''; |
||
156 | protected $post_date = ''; |
||
157 | |||
158 | /** |
||
159 | * The date the payment was marked as 'complete' |
||
160 | * |
||
161 | * @since 1.5 |
||
162 | * @access protected |
||
163 | * |
||
164 | * @var string |
||
165 | */ |
||
166 | protected $completed_date = ''; |
||
167 | |||
168 | /** |
||
169 | * The status of the payment |
||
170 | * |
||
171 | * @since 1.5 |
||
172 | * @access protected |
||
173 | * |
||
174 | * @var string |
||
175 | */ |
||
176 | protected $status = 'pending'; |
||
177 | protected $post_status = 'pending'; // Same as $status but here for backwards compat |
||
178 | |||
179 | /** |
||
180 | * When updating, the old status prior to the change |
||
181 | * |
||
182 | * @since 1.5 |
||
183 | * @access protected |
||
184 | * |
||
185 | * @var string |
||
186 | */ |
||
187 | protected $old_status = ''; |
||
188 | |||
189 | /** |
||
190 | * The display name of the current payment status |
||
191 | * |
||
192 | * @since 1.5 |
||
193 | * @access protected |
||
194 | * |
||
195 | * @var string |
||
196 | */ |
||
197 | protected $status_nicename = ''; |
||
198 | |||
199 | /** |
||
200 | * The customer ID that made the payment |
||
201 | * |
||
202 | * @since 1.5 |
||
203 | * @access protected |
||
204 | * |
||
205 | * @var integer |
||
206 | */ |
||
207 | protected $customer_id = null; |
||
208 | |||
209 | /** |
||
210 | * The User ID (if logged in) that made the payment |
||
211 | * |
||
212 | * @since 1.5 |
||
213 | * @access protected |
||
214 | * |
||
215 | * @var integer |
||
216 | */ |
||
217 | protected $user_id = 0; |
||
218 | |||
219 | /** |
||
220 | * The first name of the payee |
||
221 | * |
||
222 | * @since 1.5 |
||
223 | * @access protected |
||
224 | * |
||
225 | * @var string |
||
226 | */ |
||
227 | protected $first_name = ''; |
||
228 | |||
229 | /** |
||
230 | * The last name of the payee |
||
231 | * |
||
232 | * @since 1.5 |
||
233 | * @access protected |
||
234 | * |
||
235 | * @var string |
||
236 | */ |
||
237 | protected $last_name = ''; |
||
238 | |||
239 | /** |
||
240 | * The email used for the payment |
||
241 | * |
||
242 | * @since 1.5 |
||
243 | * @access protected |
||
244 | * |
||
245 | * @var string |
||
246 | */ |
||
247 | protected $email = ''; |
||
248 | |||
249 | /** |
||
250 | * Legacy (not to be accessed) array of user information |
||
251 | * |
||
252 | * @since 1.5 |
||
253 | * @access private |
||
254 | * |
||
255 | * @var array |
||
256 | */ |
||
257 | private $user_info = array(); |
||
258 | |||
259 | /** |
||
260 | * Legacy (not to be accessed) payment meta array |
||
261 | * |
||
262 | * @since 1.5 |
||
263 | * @access private |
||
264 | * |
||
265 | * @var array |
||
266 | */ |
||
267 | private $payment_meta = array(); |
||
268 | |||
269 | /** |
||
270 | * The physical address used for the payment if provided |
||
271 | * |
||
272 | * @since 1.5 |
||
273 | * @access protected |
||
274 | * |
||
275 | * @var array |
||
276 | */ |
||
277 | protected $address = array(); |
||
278 | |||
279 | /** |
||
280 | * The transaction ID returned by the gateway |
||
281 | * |
||
282 | * @since 1.5 |
||
283 | * @access protected |
||
284 | * |
||
285 | * @var string |
||
286 | */ |
||
287 | protected $transaction_id = ''; |
||
288 | |||
289 | /** |
||
290 | * IP Address payment was made from |
||
291 | * |
||
292 | * @since 1.5 |
||
293 | * @access protected |
||
294 | * |
||
295 | * @var string |
||
296 | */ |
||
297 | protected $ip = ''; |
||
298 | 52 | ||
299 | /** |
||
300 | 52 | * The gateway used to process the payment |
|
301 | 52 | * |
|
302 | * @since 1.5 |
||
303 | * @access protected |
||
304 | 52 | * |
|
305 | 52 | * @var string |
|
306 | */ |
||
307 | protected $gateway = ''; |
||
308 | |||
309 | /** |
||
310 | * The the payment was made with |
||
311 | * |
||
312 | * @since 1.5 |
||
313 | * @access protected |
||
314 | * |
||
315 | * @var string |
||
316 | 52 | */ |
|
317 | protected $currency = ''; |
||
318 | 52 | ||
319 | /** |
||
320 | 52 | * Array of items that have changed since the last save() was run |
|
321 | * This is for internal use, to allow fewer update_payment_meta calls to be run |
||
322 | 52 | * |
|
323 | * @since 1.5 |
||
324 | 52 | * @access private |
|
325 | * |
||
326 | * @var array |
||
327 | */ |
||
328 | 52 | private $pending; |
|
329 | |||
330 | /** |
||
331 | * The parent payment (if applicable) |
||
332 | * |
||
333 | * @since 1.5 |
||
334 | * @access protected |
||
335 | * |
||
336 | * @var integer |
||
337 | */ |
||
338 | protected $parent_payment = 0; |
||
339 | |||
340 | /** |
||
341 | 52 | * Setup the Give Payments class |
|
342 | 52 | * |
|
343 | * @since 1.0 |
||
344 | 52 | * @access public |
|
345 | 52 | * |
|
346 | 52 | * @param int $payment_id A given payment |
|
347 | * |
||
348 | 52 | * @return mixed void|false |
|
349 | 52 | */ |
|
350 | 52 | public function __construct( $payment_id = false ) { |
|
358 | |||
359 | /** |
||
360 | * Magic GET function |
||
361 | * |
||
362 | * @since 1.5 |
||
363 | * @access public |
||
364 | * |
||
365 | * @param string $key The property |
||
366 | 42 | * |
|
367 | 42 | * @return mixed The value |
|
368 | 42 | */ |
|
369 | public function __get( $key ) { |
||
383 | 52 | ||
384 | 52 | /** |
|
385 | * Magic SET function |
||
386 | 52 | * |
|
387 | * Sets up the pending array for the save method |
||
388 | * |
||
389 | * @since 1.5 |
||
390 | 52 | * @access public |
|
391 | * |
||
392 | 52 | * @param string $key The property name |
|
393 | 7 | * @param mixed $value The value of the property |
|
394 | */ |
||
395 | public function __set( $key, $value ) { |
||
410 | 52 | ||
411 | /** |
||
412 | * Magic ISSET function, which allows empty checks on protected elements |
||
413 | 52 | * |
|
414 | 52 | * @since 1.5 |
|
415 | 52 | * @access public |
|
416 | 52 | * |
|
417 | 52 | * @param string $name The attribute to get |
|
418 | 52 | * |
|
419 | 52 | * @return boolean If the item is set or not |
|
420 | */ |
||
421 | 52 | public function __isset( $name ) { |
|
428 | 52 | ||
429 | 52 | /** |
|
430 | 52 | * Setup payment properties |
|
431 | 52 | * |
|
432 | * @since 1.5 |
||
433 | * @access private |
||
434 | 52 | * |
|
435 | 52 | * @param int $payment_id The payment ID |
|
436 | * |
||
437 | * @return bool If the setup was successful or not |
||
438 | 52 | */ |
|
439 | 52 | private function setup_payment( $payment_id ) { |
|
515 | 52 | ||
516 | 52 | /** |
|
517 | 52 | * Payment class object is storing various meta value in object parameter. |
|
518 | 52 | * So if user is updating payment meta but not updating payment object, then payment meta values will not reflect/changes on payment meta automatically |
|
519 | 52 | * and you can still access payment meta old value in any old payment object ( previously created ) which can cause to show or save wrong payment data. |
|
520 | 52 | * To prevent that user can use this function after updating any payment meta value ( in bulk or single update ). |
|
521 | 52 | * |
|
522 | * @since 1.6 |
||
523 | * @access public |
||
524 | 52 | * |
|
525 | * @param int $payment_id Payment ID. |
||
526 | 52 | * |
|
527 | * @return void |
||
528 | 52 | */ |
|
529 | 52 | public function update_payment_setup( $payment_id ){ |
|
532 | |||
533 | 52 | /** |
|
534 | * Create the base of a payment. |
||
535 | * |
||
536 | * @since 1.5 |
||
537 | 52 | * @access private |
|
538 | 52 | * |
|
539 | 52 | * @return int|bool False on failure, the payment ID on success. |
|
540 | */ |
||
541 | 52 | private function insert_payment() { |
|
647 | 2 | ||
648 | 2 | /** |
|
649 | 2 | * Save |
|
650 | * |
||
651 | * Once items have been set, an update is needed to save them to the database. |
||
652 | 2 | * |
|
653 | 2 | * @access public |
|
654 | 2 | * |
|
655 | 2 | * @return bool True of the save occurred, false if it failed or wasn't needed |
|
656 | */ |
||
657 | 2 | public function save() { |
|
935 | |||
936 | 52 | /** |
|
937 | 52 | * Add a donation to a given payment |
|
938 | 52 | * |
|
939 | 52 | * @since 1.5 |
|
940 | 52 | * @access public |
|
941 | 52 | * |
|
942 | 52 | * @param int $form_id The donation form to add |
|
943 | * @param array $args Other arguments to pass to the function |
||
944 | 52 | * @param array $options List of donation options |
|
945 | * |
||
946 | 52 | * @return bool True when successful, false otherwise |
|
947 | */ |
||
948 | 52 | public function add_donation( $form_id = 0, $args = array(), $options = array() ) { |
|
1031 | |||
1032 | /** |
||
1033 | * Remove a donation from the payment |
||
1034 | * |
||
1035 | * @since 1.5 |
||
1036 | * @access public |
||
1037 | * |
||
1038 | * @param int $form_id The form ID to remove |
||
1039 | * @param array $args Arguments to pass to identify (quantity, amount, price_id) |
||
1040 | * |
||
1041 | * @return bool If the item was removed or not |
||
1042 | */ |
||
1043 | public function remove_donation( $form_id, $args = array() ) { |
||
1073 | |||
1074 | /** |
||
1075 | * Add a fee to a given payment |
||
1076 | * |
||
1077 | * @since 1.5 |
||
1078 | * @access public |
||
1079 | * |
||
1080 | * @param array $args Array of arguments for the fee to add |
||
1081 | * @param bool $global |
||
1082 | * |
||
1083 | * @return bool If the fee was added |
||
1084 | */ |
||
1085 | public function add_fee( $args, $global = true ) { |
||
1108 | |||
1109 | /** |
||
1110 | * Remove a fee from the payment |
||
1111 | * |
||
1112 | * @since 1.5 |
||
1113 | * @access public |
||
1114 | * |
||
1115 | * @param int $key The array key index to remove |
||
1116 | * |
||
1117 | * @return bool If the fee was removed successfully |
||
1118 | */ |
||
1119 | public function remove_fee( $key ) { |
||
1128 | |||
1129 | /** |
||
1130 | * Remove a fee by the defined attributed |
||
1131 | * |
||
1132 | * @since 1.5 |
||
1133 | * @access public |
||
1134 | * |
||
1135 | * @param string $key The key to remove by |
||
1136 | * @param int|string $value The value to search for |
||
1137 | * @param boolean $global False - removes the first value it fines, |
||
1138 | * True - removes all matches. |
||
1139 | * |
||
1140 | * @return boolean If the item is removed |
||
1141 | */ |
||
1142 | public function remove_fee_by( $key, $value, $global = false ) { |
||
1198 | |||
1199 | /** |
||
1200 | * Get the fees, filterable by type |
||
1201 | * |
||
1202 | * @since 1.5 |
||
1203 | * @access public |
||
1204 | * |
||
1205 | * @param string $type All, item, fee |
||
1206 | * |
||
1207 | * @return array The Fees for the type specified |
||
1208 | */ |
||
1209 | public function get_fees( $type = 'all' ) { |
||
1228 | |||
1229 | /** |
||
1230 | * Add a note to a payment |
||
1231 | * |
||
1232 | * @since 1.0 |
||
1233 | * @access public |
||
1234 | * |
||
1235 | * @param string $note The note to add |
||
1236 | * |
||
1237 | * @return void |
||
1238 | */ |
||
1239 | public function add_note( $note = false ) { |
||
1247 | |||
1248 | /** |
||
1249 | * Increase the payment's subtotal |
||
1250 | * |
||
1251 | * @since 1.5 |
||
1252 | * @access private |
||
1253 | * |
||
1254 | 52 | * @param float $amount The amount to increase the payment subtotal by |
|
1255 | * |
||
1256 | * @return void |
||
1257 | 52 | */ |
|
1258 | 39 | private function increase_subtotal( $amount = 0.00 ) { |
|
1264 | 52 | ||
1265 | /** |
||
1266 | * Decrease the payment's subtotal |
||
1267 | 42 | * |
|
1268 | * @since 1.5 |
||
1269 | 42 | * @access private |
|
1270 | * |
||
1271 | * @param float $amount The amount to decrease the payment subtotal by |
||
1272 | 42 | * |
|
1273 | * @return void |
||
1274 | 42 | */ |
|
1275 | private function decrease_subtotal( $amount = 0.00 ) { |
||
1285 | 42 | ||
1286 | /** |
||
1287 | * Increase the payment's subtotal |
||
1288 | * |
||
1289 | 42 | * @since 1.5 |
|
1290 | 4 | * @access private |
|
1291 | 4 | * |
|
1292 | 42 | * @param float $amount The amount to increase the payment subtotal by |
|
1293 | * |
||
1294 | * @return void |
||
1295 | 42 | */ |
|
1296 | 3 | private function increase_fees( $amount = 0.00 ) { |
|
1302 | 42 | ||
1303 | /** |
||
1304 | 42 | * Decrease the payment's subtotal |
|
1305 | * |
||
1306 | * @since 1.5 |
||
1307 | * @access private |
||
1308 | * |
||
1309 | * @param float $amount The amount to decrease the payment subtotal by |
||
1310 | * |
||
1311 | * @return void |
||
1312 | */ |
||
1313 | private function decrease_fees( $amount = 0.00 ) { |
||
1323 | |||
1324 | /** |
||
1325 | * Set or update the total for a payment |
||
1326 | * |
||
1327 | * @since 1.0 |
||
1328 | * @access private |
||
1329 | * |
||
1330 | * @return void |
||
1331 | */ |
||
1332 | 52 | private function recalculate_total() { |
|
1335 | |||
1336 | 52 | /** |
|
1337 | * Set the payment status and run any status specific changes necessary |
||
1338 | 52 | * |
|
1339 | 52 | * @since 1.0 |
|
1340 | 52 | * @access public |
|
1341 | * |
||
1342 | 52 | * @param string $status The status to set the payment to |
|
1343 | 52 | * |
|
1344 | 52 | * @return bool $updated Returns if the status was successfully updated |
|
1345 | */ |
||
1346 | 52 | public function update_status( $status = false ) { |
|
1405 | |||
1406 | /** |
||
1407 | * Change the status of the payment to refunded, and run the necessary changes |
||
1408 | * |
||
1409 | 4 | * @since 1.5 |
|
1410 | 4 | * @access public |
|
1411 | * |
||
1412 | * @return void |
||
1413 | 4 | */ |
|
1414 | public function refund() { |
||
1421 | |||
1422 | /** |
||
1423 | * Get a post meta item for the payment |
||
1424 | 4 | * |
|
1425 | * @since 1.5 |
||
1426 | 4 | * @access public |
|
1427 | 4 | * |
|
1428 | 4 | * @param string $meta_key The Meta Key |
|
1429 | * @param boolean $single Return single item or array |
||
1430 | 4 | * |
|
1431 | 4 | * @return mixed The value from the post meta |
|
1432 | */ |
||
1433 | public function get_meta( $meta_key = '_give_payment_meta', $single = true ) { |
||
1460 | 3 | ||
1461 | 1 | /** |
|
1462 | 1 | * Update the post meta |
|
1463 | * |
||
1464 | * @since 1.5 |
||
1465 | 3 | * @access public |
|
1466 | * |
||
1467 | 3 | * @param string $meta_key The meta key to update |
|
1468 | 1 | * @param string $meta_value The meta value |
|
1469 | * @param string $prev_value Previous meta value |
||
1470 | * |
||
1471 | 2 | * @return int|bool Meta ID if the key didn't exist, true on successful update, false on failure |
|
1472 | 2 | */ |
|
1473 | 2 | public function update_meta( $meta_key = '', $meta_value = '', $prev_value = '' ) { |
|
1503 | 4 | ||
1504 | /** |
||
1505 | * When a payment is set to a status of 'refunded' process the necessary actions to reduce stats |
||
1506 | 6 | * |
|
1507 | * @since 1.5 |
||
1508 | 6 | * @access private |
|
1509 | * |
||
1510 | 6 | * @return void |
|
1511 | 4 | */ |
|
1512 | 4 | private function process_refund() { |
|
1541 | 6 | ||
1542 | 6 | /** |
|
1543 | * Process when a payment is set to failed |
||
1544 | * |
||
1545 | * @since 1.5 |
||
1546 | * @access private |
||
1547 | * |
||
1548 | * @return void |
||
1549 | */ |
||
1550 | private function process_failure() { |
||
1553 | |||
1554 | /** |
||
1555 | * Process when a payment moves to pending |
||
1556 | * |
||
1557 | * @since 1.5 |
||
1558 | * @access private |
||
1559 | 52 | * |
|
1560 | 52 | * @return void |
|
1561 | */ |
||
1562 | 52 | private function process_pending() { |
|
1590 | 52 | ||
1591 | 2 | /** |
|
1592 | 2 | * Process when a payment moves to cancelled |
|
1593 | * |
||
1594 | 2 | * @since 1.5 |
|
1595 | * @access private |
||
1596 | * |
||
1597 | 2 | * @return void |
|
1598 | */ |
||
1599 | 52 | private function process_cancelled() { |
|
1627 | |||
1628 | /** |
||
1629 | * Process when a payment moves to revoked |
||
1630 | 52 | * |
|
1631 | * @since 1.5 |
||
1632 | * @return void |
||
1633 | */ |
||
1634 | private function process_revoked() { |
||
1662 | |||
1663 | /** |
||
1664 | 52 | * Used during the process of moving to refunded or pending, to decrement stats |
|
1665 | 52 | * |
|
1666 | * @since 1.5 |
||
1667 | 52 | * @access private |
|
1668 | * |
||
1669 | * @param bool $alter_store_earnings If the method should alter the store earnings |
||
1670 | * @param bool $alter_customer_value If the method should reduce the customer value |
||
1671 | * @param bool $alter_customer_purchase_count If the method should reduce the customer's purchase count |
||
1672 | * |
||
1673 | * @return void |
||
1674 | */ |
||
1675 | private function maybe_alter_stats( $alter_store_earnings, $alter_customer_value, $alter_customer_purchase_count ) { |
||
1700 | |||
1701 | /** |
||
1702 | * Delete sales logs for this purchase |
||
1703 | * |
||
1704 | * @since 1.5 |
||
1705 | * @access private |
||
1706 | * |
||
1707 | 52 | * @return void |
|
1708 | 52 | */ |
|
1709 | private function delete_sales_logs() { |
||
1724 | |||
1725 | /** |
||
1726 | * Setup functions only, these are not to be used by developers. |
||
1727 | * These functions exist only to allow the setup routine to be backwards compatible with our old |
||
1728 | * helper functions. |
||
1729 | * |
||
1730 | * These will run whenever setup_payment is called, which should only be called once. |
||
1731 | 52 | * To update an attribute, update it directly instead of re-running the setup routine |
|
1732 | 52 | */ |
|
1733 | |||
1734 | 52 | /** |
|
1735 | 2 | * Setup the payment completed date |
|
1736 | 2 | * |
|
1737 | * @since 1.5 |
||
1738 | 52 | * @access private |
|
1739 | * |
||
1740 | * @return string The date the payment was completed |
||
1741 | */ |
||
1742 | private function setup_completed_date() { |
||
1753 | 52 | ||
1754 | 52 | /** |
|
1755 | * Setup the payment mode |
||
1756 | 52 | * |
|
1757 | * @since 1.5 |
||
1758 | * @access private |
||
1759 | * |
||
1760 | * @return string The payment mode |
||
1761 | */ |
||
1762 | private function setup_mode() { |
||
1765 | |||
1766 | /** |
||
1767 | * Setup the payment total |
||
1768 | * |
||
1769 | * @since 1.5 |
||
1770 | * @access private |
||
1771 | 52 | * |
|
1772 | 52 | * @return float The payment total |
|
1773 | 52 | */ |
|
1774 | 52 | private function setup_total() { |
|
1788 | |||
1789 | 21 | /** |
|
1790 | 21 | * Setup the payment subtotal |
|
1791 | * |
||
1792 | * @since 1.5 |
||
1793 | * @access private |
||
1794 | * |
||
1795 | * @return float The subtotal of the payment |
||
1796 | 52 | */ |
|
1797 | private function setup_subtotal() { |
||
1802 | |||
1803 | /** |
||
1804 | * Setup the payment fees |
||
1805 | * |
||
1806 | * @since 1.5 |
||
1807 | * @access private |
||
1808 | * |
||
1809 | * @return float The fees total for the payment |
||
1810 | */ |
||
1811 | 52 | private function setup_fees_total() { |
|
1824 | |||
1825 | /** |
||
1826 | * Setup the currency code |
||
1827 | * |
||
1828 | * @since 1.5 |
||
1829 | * @access private |
||
1830 | * |
||
1831 | 52 | * @return string The currency for the payment |
|
1832 | */ |
||
1833 | 52 | private function setup_currency() { |
|
1838 | |||
1839 | /** |
||
1840 | * Setup any fees associated with the payment |
||
1841 | * |
||
1842 | * @since 1.5 |
||
1843 | * @access private |
||
1844 | 52 | * |
|
1845 | * @return array The Fees |
||
1846 | 52 | */ |
|
1847 | private function setup_fees() { |
||
1852 | |||
1853 | /** |
||
1854 | * Setup the gateway used for the payment |
||
1855 | * |
||
1856 | * @since 1.5 |
||
1857 | 52 | * @access private |
|
1858 | 52 | * |
|
1859 | * @return string The gateway |
||
1860 | 52 | */ |
|
1861 | private function setup_gateway() { |
||
1866 | |||
1867 | /** |
||
1868 | * Setup the transaction ID |
||
1869 | 52 | * |
|
1870 | 52 | * @since 1.5 |
|
1871 | * @access private |
||
1872 | 52 | * |
|
1873 | * @return string The transaction ID for the payment |
||
1874 | */ |
||
1875 | private function setup_transaction_id() { |
||
1887 | |||
1888 | 20 | /** |
|
1889 | * Setup the IP Address for the payment |
||
1890 | 2 | * |
|
1891 | * @since 1.5 |
||
1892 | 2 | * @access private |
|
1893 | * |
||
1894 | 20 | * @return string The IP address for the payment |
|
1895 | */ |
||
1896 | 52 | private function setup_ip() { |
|
1901 | |||
1902 | /** |
||
1903 | * Setup the customer ID |
||
1904 | * |
||
1905 | * @since 1.5 |
||
1906 | * @access private |
||
1907 | * |
||
1908 | * @return int The Customer ID |
||
1909 | */ |
||
1910 | private function setup_customer_id() { |
||
1915 | 42 | ||
1916 | /** |
||
1917 | * Setup the User ID associated with the purchase |
||
1918 | * |
||
1919 | * @since 1.5 |
||
1920 | * @access private |
||
1921 | * |
||
1922 | * @return int The User ID |
||
1923 | */ |
||
1924 | private function setup_user_id() { |
||
1929 | |||
1930 | /** |
||
1931 | * Setup the email address for the purchase |
||
1932 | * |
||
1933 | * @since 1.5 |
||
1934 | 42 | * @access private |
|
1935 | 42 | * |
|
1936 | * @return string The email address for the payment |
||
1937 | */ |
||
1938 | private function setup_email() { |
||
1947 | |||
1948 | /** |
||
1949 | * Setup the user info |
||
1950 | * |
||
1951 | * @since 1.5 |
||
1952 | * @access private |
||
1953 | * |
||
1954 | 11 | * @return array The user info associated with the payment |
|
1955 | 11 | */ |
|
1956 | private function setup_user_info() { |
||
2013 | |||
2014 | /** |
||
2015 | * Setup the Address for the payment |
||
2016 | * |
||
2017 | * @since 1.5 |
||
2018 | * @access private |
||
2019 | * |
||
2020 | * @return array The Address information for the payment |
||
2021 | */ |
||
2022 | private function setup_address() { |
||
2035 | 52 | ||
2036 | /** |
||
2037 | * Setup the form title |
||
2038 | * |
||
2039 | * @since 1.5 |
||
2040 | * @access private |
||
2041 | * |
||
2042 | * @return string The Form Title |
||
2043 | */ |
||
2044 | 42 | private function setup_form_title() { |
|
2050 | |||
2051 | /** |
||
2052 | * Setup the form ID |
||
2053 | * |
||
2054 | * @since 1.5 |
||
2055 | * @access private |
||
2056 | * |
||
2057 | * @return int The Form ID |
||
2058 | */ |
||
2059 | private function setup_form_id() { |
||
2065 | |||
2066 | /** |
||
2067 | * Setup the price ID |
||
2068 | * |
||
2069 | * @since 1.5 |
||
2070 | * @access private |
||
2071 | * |
||
2072 | * @return int The Form Price ID |
||
2073 | */ |
||
2074 | private function setup_price_id() { |
||
2079 | |||
2080 | /** |
||
2081 | * Setup the payment key |
||
2082 | * |
||
2083 | * @since 1.5 |
||
2084 | * @access private |
||
2085 | * |
||
2086 | * @return string The Payment Key |
||
2087 | */ |
||
2088 | private function setup_payment_key() { |
||
2093 | |||
2094 | /** |
||
2095 | * Setup the payment number |
||
2096 | * |
||
2097 | * @since 1.5 |
||
2098 | * @access private |
||
2099 | * |
||
2100 | * @return int|string Integer by default, or string if sequential order numbers is enabled |
||
2101 | */ |
||
2102 | private function setup_payment_number() { |
||
2119 | |||
2120 | /** |
||
2121 | * Converts this object into an array for special cases |
||
2122 | * |
||
2123 | * @access public |
||
2124 | * |
||
2125 | * @return array The payment object as an array |
||
2126 | */ |
||
2127 | public function array_convert() { |
||
2130 | |||
2131 | /** |
||
2132 | * Retrieve payment completion date |
||
2133 | * |
||
2134 | * @since 1.5 |
||
2135 | * @access private |
||
2136 | * |
||
2137 | * @return string Date payment was completed |
||
2138 | */ |
||
2139 | private function get_completed_date() { |
||
2142 | |||
2143 | /** |
||
2144 | * Retrieve payment subtotal |
||
2145 | * |
||
2146 | * @since 1.5 |
||
2147 | * @access private |
||
2148 | * |
||
2149 | * @return float Payment subtotal |
||
2150 | */ |
||
2151 | private function get_subtotal() { |
||
2154 | |||
2155 | /** |
||
2156 | * Retrieve payment currency |
||
2157 | * |
||
2158 | * @since 1.5 |
||
2159 | * @access private |
||
2160 | * |
||
2161 | * @return string Payment currency code |
||
2162 | */ |
||
2163 | private function get_currency() { |
||
2166 | |||
2167 | /** |
||
2168 | * Retrieve payment gateway |
||
2169 | * |
||
2170 | * @since 1.5 |
||
2171 | * @access private |
||
2172 | * |
||
2173 | * @return string Gateway used |
||
2174 | */ |
||
2175 | private function get_gateway() { |
||
2178 | |||
2179 | /** |
||
2180 | * Retrieve payment transaction ID |
||
2181 | * |
||
2182 | * @since 1.5 |
||
2183 | * @access private |
||
2184 | * |
||
2185 | * @return string Transaction ID from merchant processor |
||
2186 | */ |
||
2187 | private function get_transaction_id() { |
||
2190 | |||
2191 | /** |
||
2192 | * Retrieve payment IP |
||
2193 | * |
||
2194 | * @since 1.5 |
||
2195 | * @access private |
||
2196 | * |
||
2197 | * @return string Payment IP address |
||
2198 | */ |
||
2199 | private function get_ip() { |
||
2202 | |||
2203 | /** |
||
2204 | * Retrieve payment customer ID |
||
2205 | * |
||
2206 | * @since 1.5 |
||
2207 | * @access private |
||
2208 | * |
||
2209 | * @return int Payment customer ID |
||
2210 | */ |
||
2211 | private function get_customer_id() { |
||
2214 | |||
2215 | /** |
||
2216 | * Retrieve payment user ID |
||
2217 | * |
||
2218 | * @since 1.5 |
||
2219 | * @access private |
||
2220 | * |
||
2221 | * @return int Payment user ID |
||
2222 | */ |
||
2223 | private function get_user_id() { |
||
2226 | |||
2227 | /** |
||
2228 | * Retrieve payment email |
||
2229 | * |
||
2230 | * @since 1.5 |
||
2231 | * @access private |
||
2232 | * |
||
2233 | * @return string Payment customer email |
||
2234 | */ |
||
2235 | private function get_email() { |
||
2238 | |||
2239 | /** |
||
2240 | * Retrieve payment user info |
||
2241 | * |
||
2242 | * @since 1.5 |
||
2243 | * @access private |
||
2244 | * |
||
2245 | * @return array Payment user info |
||
2246 | */ |
||
2247 | private function get_user_info() { |
||
2250 | |||
2251 | /** |
||
2252 | * Retrieve payment billing address |
||
2253 | * |
||
2254 | * @since 1.5 |
||
2255 | * @access private |
||
2256 | * |
||
2257 | * @return array Payment billing address |
||
2258 | */ |
||
2259 | private function get_address() { |
||
2262 | |||
2263 | /** |
||
2264 | * Retrieve payment key |
||
2265 | * |
||
2266 | * @since 1.5 |
||
2267 | * @access private |
||
2268 | * |
||
2269 | * @return string Payment key |
||
2270 | */ |
||
2271 | private function get_key() { |
||
2274 | |||
2275 | /** |
||
2276 | * Retrieve payment form id |
||
2277 | * |
||
2278 | * @since 1.5 |
||
2279 | * @access private |
||
2280 | * |
||
2281 | * @return string Payment form id |
||
2282 | */ |
||
2283 | private function get_form_id() { |
||
2286 | |||
2287 | /** |
||
2288 | * Retrieve payment number |
||
2289 | * |
||
2290 | * @since 1.5 |
||
2291 | * @access private |
||
2292 | * |
||
2293 | * @return int|string Payment number |
||
2294 | */ |
||
2295 | private function get_number() { |
||
2298 | |||
2299 | } |
||
2300 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.