| Conditions | 14 | 
| Paths | 14 | 
| Total Lines | 30 | 
| Code Lines | 22 | 
| 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  | 
            ||
| 85 | protected function getSearchQueryWriter(SearchCriterion $searchCriterion)  | 
            ||
| 86 |     { | 
            ||
| 87 |         if ($searchCriterion->getSearchQueryWriter() instanceof AbstractSearchQueryWriter) { | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 88 | // The user has defined their own SearchQueryWriter, so we should just return it.  | 
            ||
| 89 | return $searchCriterion->getSearchQueryWriter();  | 
            ||
| 90 | }  | 
            ||
| 91 | |||
| 92 |         switch ($searchCriterion->getComparison()) { | 
            ||
| 93 | case SearchCriterion::EQUAL:  | 
            ||
| 94 | case SearchCriterion::NOT_EQUAL:  | 
            ||
| 95 | return SolrSearchQueryWriterBasic::create();  | 
            ||
| 96 | case SearchCriterion::IN:  | 
            ||
| 97 | case SearchCriterion::NOT_IN:  | 
            ||
| 98 | return SolrSearchQueryWriterIn::create();  | 
            ||
| 99 | case SearchCriterion::GREATER_EQUAL:  | 
            ||
| 100 | case SearchCriterion::GREATER_THAN:  | 
            ||
| 101 | case SearchCriterion::LESS_EQUAL:  | 
            ||
| 102 | case SearchCriterion::LESS_THAN:  | 
            ||
| 103 | case SearchCriterion::ISNULL:  | 
            ||
| 104 | case SearchCriterion::ISNOTNULL:  | 
            ||
| 105 | return SolrSearchQueryWriterRange::create();  | 
            ||
| 106 | case SearchCriterion::CUSTOM:  | 
            ||
| 107 | // CUSTOM requires a SearchQueryWriter be provided.  | 
            ||
| 108 |                 if (!$searchCriterion->getSearchQueryWriter() instanceof AbstractSearchQueryWriter) { | 
            ||
| 109 |                     throw new \InvalidArgumentException('SearchQueryWriter undefined or unsupported in SearchCriterion'); | 
            ||
| 110 | }  | 
            ||
| 111 | |||
| 112 | return $searchCriterion->getSearchQueryWriter();  | 
            ||
| 113 | default:  | 
            ||
| 114 |                 throw new \InvalidArgumentException('Unsupported comparison type in SolrSearchAdapter'); | 
            ||
| 115 | }  | 
            ||
| 118 |