| Conditions | 10 |
| Paths | 96 |
| Total Lines | 62 |
| 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 |
||
| 79 | public function buildModelCriteria() |
||
| 80 | { |
||
| 81 | $query = new FeatureTypeQuery(); |
||
| 82 | |||
| 83 | /* manage translations */ |
||
| 84 | $this->configureI18nProcessing($query, array('TITLE', 'DESCRIPTION')); |
||
| 85 | |||
| 86 | if (null !== $id = $this->getId()) { |
||
| 87 | $query->filterById($id); |
||
| 88 | } |
||
| 89 | |||
| 90 | if (null !== $id = $this->getExcludeId()) { |
||
| 91 | $query->filterById($id, Criteria::NOT_IN); |
||
| 92 | } |
||
| 93 | |||
| 94 | if (null !== $slug = $this->getSlug()) { |
||
| 95 | $query->filterBySlug($slug); |
||
| 96 | } |
||
| 97 | |||
| 98 | if (null !== $featureId = $this->getFeatureId()) { |
||
| 99 | $join = new Join(); |
||
| 100 | |||
| 101 | $join->addExplicitCondition( |
||
| 102 | FeatureTypeTableMap::TABLE_NAME, |
||
| 103 | 'ID', |
||
| 104 | null, |
||
| 105 | FeatureFeatureTypeTableMap::TABLE_NAME, |
||
| 106 | 'FEATURE_TYPE_ID', |
||
| 107 | null |
||
| 108 | ); |
||
| 109 | |||
| 110 | $join->setJoinType(Criteria::JOIN); |
||
| 111 | |||
| 112 | $query |
||
| 113 | ->addJoinObject($join, 'feature_type_join') |
||
| 114 | ->addJoinCondition( |
||
| 115 | 'feature_type_join', |
||
| 116 | '`feature_feature_type`.`feature_id` IN (?)', |
||
| 117 | implode(',', $featureId), |
||
| 118 | null, |
||
| 119 | \PDO::PARAM_INT |
||
| 120 | ); |
||
| 121 | } |
||
| 122 | |||
| 123 | foreach ($this->getOrder() as $order) { |
||
| 124 | switch ($order) { |
||
| 125 | case "id": |
||
| 126 | $query->orderById(); |
||
| 127 | break; |
||
| 128 | case "id-reverse": |
||
| 129 | $query->orderById(Criteria::DESC); |
||
| 130 | break; |
||
| 131 | case "slug": |
||
| 132 | $query->orderBySlug(); |
||
| 133 | break; |
||
| 134 | case "slug-reverse": |
||
| 135 | $query->orderBySlug(Criteria::DESC); |
||
| 136 | break; |
||
| 137 | } |
||
| 138 | } |
||
| 139 | return $query; |
||
| 140 | } |
||
| 141 | |||
| 178 |