Conditions | 13 |
Paths | 1056 |
Total Lines | 57 |
Code Lines | 33 |
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 |
||
66 | public function sourceRecords($params, $sort, $limit) |
||
67 | { |
||
68 | $return = ArrayList::create(); |
||
69 | |||
70 | // Check filters |
||
71 | $where_filter = []; |
||
72 | |||
73 | $where_filter[] = (isset($params['Filter_Year'])) ? "YEAR(\"Created\") = '{$params['Filter_Year']}'" : "YEAR(\"Created\") = '".date('Y')."'"; |
||
74 | if (!empty($params['Filter_Month'])) { |
||
75 | $where_filter[] = "Month(\"Created\") = '{$params['Filter_Month']}'"; |
||
76 | } |
||
77 | if (!empty($params['Filter_Status'])) { |
||
78 | $where_filter[] = "Status = '{$params['Filter_Status']}'"; |
||
79 | } |
||
80 | if (!empty($params['Filter_FirstName'])) { |
||
81 | $where_filter[] = "FirstName = '{$params['Filter_FirstName']}'"; |
||
82 | } |
||
83 | if (!empty($params['Filter_Surname'])) { |
||
84 | $where_filter[] = "Surname = '{$params['Filter_Surname']}'"; |
||
85 | } |
||
86 | |||
87 | $orders = Invoice::get() |
||
88 | ->where(implode(' AND ', $where_filter)); |
||
89 | |||
90 | foreach ($orders as $order) { |
||
91 | // Setup a filter for our order items |
||
92 | $filter = array(); |
||
93 | |||
94 | if (!empty($params['Filter_ProductName'])) { |
||
95 | $filter["Title:PartialMatch"] = $params['Filter_ProductName']; |
||
96 | } |
||
97 | |||
98 | if (!empty($params['Filter_StockID'])) { |
||
99 | $filter["StockID"] = $params['Filter_StockID']; |
||
100 | } |
||
101 | |||
102 | $list = (count($filter)) ? $order->Items()->filter($filter) : $order->Items(); |
||
103 | |||
104 | foreach ($list as $order_item) { |
||
105 | if ($order_item->StockID) { |
||
106 | if ($list_item = $return->find("StockID", $order_item->StockID)) { |
||
107 | $list_item->Quantity = $list_item->Quantity + $order_item->Quantity; |
||
108 | } else { |
||
109 | $report_item = LineItemReportItem::create(); |
||
110 | $report_item->ID = $order_item->StockID; |
||
111 | $report_item->StockID = $order_item->StockID; |
||
112 | $report_item->Details = $order_item->Title; |
||
113 | $report_item->Price = $order_item->Price; |
||
114 | $report_item->Quantity = $order_item->Quantity; |
||
115 | |||
116 | $return->add($report_item); |
||
117 | } |
||
118 | } |
||
119 | } |
||
120 | } |
||
121 | |||
122 | return $return; |
||
123 | } |
||
215 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths