| Conditions | 10 |
| Paths | 9 |
| Total Lines | 35 |
| Code Lines | 26 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 1 |
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 |
||
| 48 | public function convert($filter, $queryResponse) |
||
| 49 | { |
||
| 50 | $this->filter = $filter; |
||
| 51 | $response = $queryResponse->getResponse(); |
||
|
|
|||
| 52 | $propertiesMap = $filter->getPropertiesMap(); |
||
| 53 | $class = $filter->getEntityClass(); |
||
| 54 | $entities = []; |
||
| 55 | foreach($response['response']['docs'] as $doc){ |
||
| 56 | $ob = new $class(); |
||
| 57 | $properties = $doc->getPropertyNames(); |
||
| 58 | foreach($properties as $name){ |
||
| 59 | $setter = 'set'.$name; |
||
| 60 | $value = $doc->$name; |
||
| 61 | $value = $this->validateDate($value); |
||
| 62 | if ($value instanceof \SolrObject) { |
||
| 63 | if ($name == 'locations') { |
||
| 64 | $this->useGeoLocation=true; |
||
| 65 | } |
||
| 66 | $this->handleMappedProperty($propertiesMap[$name],$ob,$value); |
||
| 67 | } elseif (method_exists($ob,$setter) && !$value instanceof \SolrObject){ |
||
| 68 | if ($name != 'location') { |
||
| 69 | call_user_func(array($ob, $setter), $value); |
||
| 70 | }elseif (!$this->useGeoLocation) { |
||
| 71 | call_user_func(array($ob, $setter), $value); |
||
| 72 | } |
||
| 73 | }elseif(isset($propertiesMap[$name])){ |
||
| 74 | $this->handleMappedProperty($propertiesMap[$name],$ob,$value); |
||
| 75 | } |
||
| 76 | |||
| 77 | } |
||
| 78 | $entities[] = $ob; |
||
| 79 | } |
||
| 80 | |||
| 81 | return $entities; |
||
| 82 | } |
||
| 83 | |||
| 129 | } |
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.