Conditions | 15 |
Paths | 1008 |
Total Lines | 78 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
29 | public function run($request) |
||
30 | { |
||
31 | //IMPORTANT! |
||
32 | if (! $this->sendEmails) { |
||
33 | Config::inst()->update('Email', 'send_all_emails_to', 'no-one@localhost'); |
||
34 | Email::set_mailer(new Ecommerce_Dummy_Mailer()); |
||
|
|||
35 | } |
||
36 | |||
37 | //get limits |
||
38 | $limit = null; |
||
39 | if (isset($_GET['limit'])) { |
||
40 | $limit = intval($_GET['limit']); |
||
41 | } |
||
42 | if (!intval($limit)) { |
||
43 | $limit = $this->limit; |
||
44 | } |
||
45 | $startAt = null; |
||
46 | if (isset($_GET['startat'])) { |
||
47 | $startAt = intval($_GET['startat']); |
||
48 | } |
||
49 | if (!intval($startAt)) { |
||
50 | $startAt = intval(Session::get('EcommerceTaskTryToFinaliseOrders')); |
||
51 | if (!$startAt) { |
||
52 | $startAt = 0; |
||
53 | } |
||
54 | } |
||
55 | |||
56 | //we exclude all orders that are in the queue |
||
57 | $queueObjectSingleton = Injector::inst()->get('OrderProcessQueue'); |
||
58 | $ordersinQueue = $queueObjectSingleton->AllOrdersInQueue(); |
||
59 | //find any other order that may need help ... |
||
60 | |||
61 | $submittedOrderStatusLogClassName = EcommerceConfig::get('OrderStatusLog', 'order_status_log_class_used_for_submitting_order'); |
||
62 | if ($submittedOrderStatusLogClassName) { |
||
63 | $submittedStatusLog = DataObject::get_one($submittedOrderStatusLogClassName); |
||
64 | if ($submittedStatusLog) { |
||
65 | $lastOrderStep = OrderStep::last_order_step(); |
||
66 | if ($lastOrderStep) { |
||
67 | if ($this->isCli()) { |
||
68 | $sort = 'RAND() ASC'; |
||
69 | } else { |
||
70 | $sort = array('ID' => 'ASC'); |
||
71 | } |
||
72 | $ordersInQueueArray = $ordersinQueue->column('ID'); |
||
73 | if(is_array($ordersInQueueArray) && count($ordersInQueueArray)) { |
||
74 | //do nothing... |
||
75 | } else { |
||
76 | $ordersInQueueArray = [-1 => -1]; |
||
77 | } |
||
78 | $orders = Order::get() |
||
79 | ->sort($sort) |
||
80 | ->where('StatusID <> ' . $lastOrderStep->ID) |
||
81 | ->exclude(['ID' => $ordersInQueueArray]) |
||
82 | ->innerJoin( |
||
83 | 'OrderStatusLog', |
||
84 | "\"OrderStatusLog\".\"OrderID\" = \"Order\".\"ID\"" |
||
85 | ) |
||
86 | ->innerJoin( |
||
87 | $submittedOrderStatusLogClassName, |
||
88 | "\"$submittedOrderStatusLogClassName\".\"ID\" = \"OrderStatusLog\".\"ID\"" |
||
89 | ); |
||
90 | $startAt = $this->tryToFinaliseOrders($orders, $limit, $startAt); |
||
91 | } else { |
||
92 | DB::alteration_message('NO order step.', 'deleted'); |
||
93 | } |
||
94 | } else { |
||
95 | DB::alteration_message('NO submitted order status log.', 'deleted'); |
||
96 | } |
||
97 | } else { |
||
98 | DB::alteration_message('NO EcommerceConfig::get("OrderStatusLog", "order_status_log_class_used_for_submitting_order")', 'deleted'); |
||
99 | } |
||
100 | if (Session::get('EcommerceTaskTryToFinaliseOrders')) { |
||
101 | if (! $this->isCli()) { |
||
102 | DB::alteration_message('WAIT: we are still moving more orders ... this page will automatically load the next lot in 5 seconds.', 'deleted'); |
||
103 | echo '<script type="text/javascript">window.setTimeout(function() {location.reload();}, 5000);</script>'; |
||
104 | } |
||
105 | } |
||
106 | } |
||
107 | |||
153 |
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.