| Conditions | 1 | 
| Paths | 1 | 
| Total Lines | 238 | 
| Code Lines | 129 | 
| 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 | ||
| 31 | public function getFacetedSearches() | ||
| 32 |     { | ||
| 33 | $queryClass = static::QUERY_CLASS; | ||
| 34 | $fixtureDir = $this->getFixtureDir(); | ||
|  | |||
| 35 | |||
| 36 | return array( | ||
| 37 | array( | ||
| 38 | new $queryClass( | ||
| 39 | array( | ||
| 40 | 'filter' => new Criterion\SectionId(array(1)), | ||
| 41 | 'offset' => 0, | ||
| 42 | 'limit' => 10, | ||
| 43 | 'facetBuilders' => array( | ||
| 44 | new FacetBuilder\ContentTypeFacetBuilder( | ||
| 45 | array( | ||
| 46 | 'name' => 'type', | ||
| 47 | ) | ||
| 48 | ), | ||
| 49 | ), | ||
| 50 | 'sortClauses' => array(new SortClause\ContentId()), | ||
| 51 | ) | ||
| 52 | ), | ||
| 53 | $fixtureDir . '/FacetContentType.php', | ||
| 54 | ), | ||
| 55 | array( | ||
| 56 | new $queryClass( | ||
| 57 | array( | ||
| 58 | 'filter' => new Criterion\SectionId(array(1)), | ||
| 59 | 'offset' => 0, | ||
| 60 | 'limit' => 10, | ||
| 61 | 'facetBuilders' => array( | ||
| 62 | new FacetBuilder\ContentTypeFacetBuilder( | ||
| 63 | array( | ||
| 64 | 'name' => 'type', | ||
| 65 | 'minCount' => 3, | ||
| 66 | ) | ||
| 67 | ), | ||
| 68 | ), | ||
| 69 | 'sortClauses' => array(new SortClause\ContentId()), | ||
| 70 | ) | ||
| 71 | ), | ||
| 72 | $fixtureDir . '/FacetContentTypeMinCount.php', | ||
| 73 | ), | ||
| 74 | array( | ||
| 75 | new $queryClass( | ||
| 76 | array( | ||
| 77 | 'filter' => new Criterion\SectionId(array(1)), | ||
| 78 | 'offset' => 0, | ||
| 79 | 'limit' => 10, | ||
| 80 | 'facetBuilders' => array( | ||
| 81 | new FacetBuilder\ContentTypeFacetBuilder( | ||
| 82 | array( | ||
| 83 | 'name' => 'type', | ||
| 84 | 'limit' => 5, | ||
| 85 | ) | ||
| 86 | ), | ||
| 87 | ), | ||
| 88 | 'sortClauses' => array(new SortClause\ContentId()), | ||
| 89 | ) | ||
| 90 | ), | ||
| 91 | $fixtureDir . '/FacetContentTypeMinLimit.php', | ||
| 92 | ), | ||
| 93 | array( | ||
| 94 | new $queryClass( | ||
| 95 | array( | ||
| 96 | 'filter' => new Criterion\SectionId(array(1)), | ||
| 97 | 'offset' => 0, | ||
| 98 | 'limit' => 10, | ||
| 99 | 'facetBuilders' => array( | ||
| 100 | new FacetBuilder\SectionFacetBuilder( | ||
| 101 | array( | ||
| 102 | 'name' => 'section', | ||
| 103 | ) | ||
| 104 | ), | ||
| 105 | ), | ||
| 106 | 'sortClauses' => array(new SortClause\ContentId()), | ||
| 107 | ) | ||
| 108 | ), | ||
| 109 | $fixtureDir . '/FacetSection.php', | ||
| 110 | ), | ||
| 111 | array( | ||
| 112 | new $queryClass( | ||
| 113 | array( | ||
| 114 | 'filter' => new Criterion\SectionId(array(1)), | ||
| 115 | 'offset' => 0, | ||
| 116 | 'limit' => 10, | ||
| 117 | 'facetBuilders' => array( | ||
| 118 | new FacetBuilder\UserFacetBuilder( | ||
| 119 | array( | ||
| 120 | 'name' => 'creator', | ||
| 121 | ) | ||
| 122 | ), | ||
| 123 | ), | ||
| 124 | 'sortClauses' => array(new SortClause\ContentId()), | ||
| 125 | ) | ||
| 126 | ), | ||
| 127 | $fixtureDir . '/FacetUser.php', | ||
| 128 | ), | ||
| 129 | array( | ||
| 130 | new $queryClass( | ||
| 131 | array( | ||
| 132 | 'filter' => new Criterion\SectionId(array(1)), | ||
| 133 | 'offset' => 0, | ||
| 134 | 'limit' => 10, | ||
| 135 | 'facetBuilders' => array( | ||
| 136 | new FacetBuilder\TermFacetBuilder(), | ||
| 137 | ), | ||
| 138 | 'sortClauses' => array(new SortClause\ContentId()), | ||
| 139 | ) | ||
| 140 | ), | ||
| 141 | $fixtureDir . '/FacetTerm.php', | ||
| 142 | ), | ||
| 143 | /* @todo: It needs to be defined how this one is supposed to work. | ||
| 144 | array( | ||
| 145 | new $queryClass( | ||
| 146 | array( | ||
| 147 | 'filter' => new Criterion\SectionId( array( 1 ) ), | ||
| 148 | 'offset' => 0, | ||
| 149 | 'limit' => 10, | ||
| 150 | 'facetBuilders' => array( | ||
| 151 | new FacetBuilder\CriterionFacetBuilder() | ||
| 152 | ), | ||
| 153 | 'sortClauses' => array( new SortClause\ContentId() ) | ||
| 154 | ) | ||
| 155 | ), | ||
| 156 | $fixtureDir . '/FacetCriterion.php', | ||
| 157 | ), // */ | ||
| 158 | /* @todo: Add sane ranges here: | ||
| 159 | array( | ||
| 160 | new $queryClass( | ||
| 161 | array( | ||
| 162 | 'filter' => new Criterion\SectionId( array( 1 ) ), | ||
| 163 | 'offset' => 0, | ||
| 164 | 'limit' => 10, | ||
| 165 | 'facetBuilders' => array( | ||
| 166 | new FacetBuilder\DateRangeFacetBuilder( array() ) | ||
| 167 | ), | ||
| 168 | 'sortClauses' => array( new SortClause\ContentId() ) | ||
| 169 | ) | ||
| 170 | ), | ||
| 171 | $fixtureDir . '/FacetDateRange.php', | ||
| 172 | ), // */ | ||
| 173 | array( | ||
| 174 | new $queryClass( | ||
| 175 | array( | ||
| 176 | 'filter' => new Criterion\SectionId(array(1)), | ||
| 177 | 'offset' => 0, | ||
| 178 | 'limit' => 10, | ||
| 179 | 'facetBuilders' => array( | ||
| 180 | new FacetBuilder\FieldFacetBuilder( | ||
| 181 | array( | ||
| 182 |                                     'fieldPaths' => array('article/title'), | ||
| 183 | ) | ||
| 184 | ), | ||
| 185 | ), | ||
| 186 | 'sortClauses' => array(new SortClause\ContentId()), | ||
| 187 | ) | ||
| 188 | ), | ||
| 189 | $fixtureDir . '/FacetFieldSimple.php', | ||
| 190 | ), | ||
| 191 | array( | ||
| 192 | new $queryClass( | ||
| 193 | array( | ||
| 194 | 'filter' => new Criterion\SectionId(array(1)), | ||
| 195 | 'offset' => 0, | ||
| 196 | 'limit' => 10, | ||
| 197 | 'facetBuilders' => array( | ||
| 198 | new FacetBuilder\FieldFacetBuilder( | ||
| 199 | array( | ||
| 200 |                                     'fieldPaths' => array('article/title'), | ||
| 201 | 'regex' => '(a|b|c)', | ||
| 202 | ) | ||
| 203 | ), | ||
| 204 | ), | ||
| 205 | 'sortClauses' => array(new SortClause\ContentId()), | ||
| 206 | ) | ||
| 207 | ), | ||
| 208 | $fixtureDir . '/FacetFieldRegexp.php', | ||
| 209 | ), | ||
| 210 | array( | ||
| 211 | new $queryClass( | ||
| 212 | array( | ||
| 213 | 'filter' => new Criterion\SectionId(array(1)), | ||
| 214 | 'offset' => 0, | ||
| 215 | 'limit' => 10, | ||
| 216 | 'facetBuilders' => array( | ||
| 217 | new FacetBuilder\FieldFacetBuilder( | ||
| 218 | array( | ||
| 219 |                                     'fieldPaths' => array('article/title'), | ||
| 220 | 'regex' => '(a|b|c)', | ||
| 221 | 'sort' => FacetBuilder\FieldFacetBuilder::TERM_DESC, | ||
| 222 | ) | ||
| 223 | ), | ||
| 224 | ), | ||
| 225 | 'sortClauses' => array(new SortClause\ContentId()), | ||
| 226 | ) | ||
| 227 | ), | ||
| 228 | $fixtureDir . '/FacetFieldRegexpSortTerm.php', | ||
| 229 | ), | ||
| 230 | array( | ||
| 231 | new $queryClass( | ||
| 232 | array( | ||
| 233 | 'filter' => new Criterion\SectionId(array(1)), | ||
| 234 | 'offset' => 0, | ||
| 235 | 'limit' => 10, | ||
| 236 | 'facetBuilders' => array( | ||
| 237 | new FacetBuilder\FieldFacetBuilder( | ||
| 238 | array( | ||
| 239 |                                     'fieldPaths' => array('article/title'), | ||
| 240 | 'regex' => '(a|b|c)', | ||
| 241 | 'sort' => FacetBuilder\FieldFacetBuilder::COUNT_DESC, | ||
| 242 | ) | ||
| 243 | ), | ||
| 244 | ), | ||
| 245 | 'sortClauses' => array(new SortClause\ContentId()), | ||
| 246 | ) | ||
| 247 | ), | ||
| 248 | $fixtureDir . '/FacetFieldRegexpSortCount.php', | ||
| 249 | ), | ||
| 250 | /* @todo: Add sane ranges here: | ||
| 251 | array( | ||
| 252 | new $queryClass( | ||
| 253 | array( | ||
| 254 | 'filter' => new Criterion\SectionId( array( 1 ) ), | ||
| 255 | 'offset' => 0, | ||
| 256 | 'limit' => 10, | ||
| 257 | 'facetBuilders' => array( | ||
| 258 | new FacetBuilder\FieldRangeFacetBuilder( array( | ||
| 259 | 'fieldPath' => 'product/price', | ||
| 260 | ) ) | ||
| 261 | ), | ||
| 262 | 'sortClauses' => array( new SortClause\ContentId() ) | ||
| 263 | ) | ||
| 264 | ), | ||
| 265 | $fixtureDir . '/FacetFieldRegexpSortCount.php', | ||
| 266 | ), // */ | ||
| 267 | ); | ||
| 268 | } | ||
| 269 | } | ||
| 270 | 
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idableprovides a methodequalsIdthat in turn relies on the methodgetId(). If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()as an abstract method to the trait will make sure it is available.