| Conditions | 10 |
| Paths | 48 |
| Total Lines | 54 |
| Code Lines | 30 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 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 |
||
| 96 | public function getLocations(HTTPRequest $request = null) |
||
| 97 | { |
||
| 98 | if ($request === null) { |
||
| 99 | $request = $this->request; |
||
| 100 | } |
||
| 101 | |||
| 102 | $filter = $this->config()->get('base_filter'); |
||
| 103 | |||
| 104 | if ($request->getVar('category')) { |
||
| 105 | $filter['CategoryID'] = $request->getVar('category'); |
||
| 106 | } else { |
||
| 107 | if ($this->getCategories()->exists()) { |
||
| 108 | foreach ($this->getCategories() as $category) { |
||
| 109 | $filter['CategoryID'][] = $category->ID; |
||
| 110 | } |
||
| 111 | } |
||
| 112 | } |
||
| 113 | |||
| 114 | $this->extend('updateLocatorFilter', $filter, $request); |
||
| 115 | |||
| 116 | $filterAny = $this->config()->get('base_filter_any'); |
||
| 117 | $this->extend('updateLocatorFilterAny', $filterAny, $request); |
||
| 118 | |||
| 119 | $exclude = $this->config()->get('base_exclude'); |
||
| 120 | $this->extend('updateLocatorExclude', $exclude, $request); |
||
| 121 | |||
| 122 | $locations = Locator::get_locations($filter, $filterAny, $exclude); |
||
| 123 | |||
| 124 | $locations = DataToArrayListHelper::to_array_list($locations); |
||
| 125 | |||
| 126 | //allow for adjusting list post possible distance calculation |
||
| 127 | $this->extend('updateLocationList', $locations); |
||
| 128 | if ($locations->canSortBy('distance')) { |
||
| 129 | $locations = $locations->sort('distance'); |
||
| 130 | } |
||
| 131 | |||
| 132 | if ($request->getVar('address') && $request->getVar('radius')) { |
||
| 133 | $radius = $request->getVar('radius'); |
||
| 134 | $locations = $locations->filterByCallback(function ($location) use (&$radius) { |
||
| 135 | if ($radius === -1) { |
||
| 136 | return true; |
||
| 137 | } |
||
| 138 | return $location->Distance <= $radius; |
||
| 139 | }); |
||
| 140 | } |
||
| 141 | |||
| 142 | //allow for returning list to be set as |
||
| 143 | $this->extend('updateListType', $locations); |
||
| 144 | $limit = Config::inst()->get(LocatorController::class, 'limit'); |
||
| 145 | if ($limit > 0) { |
||
| 146 | $locations = $locations->limit($limit); |
||
| 147 | } |
||
| 148 | |||
| 149 | return $locations; |
||
| 150 | } |
||
| 152 |
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