| Conditions | 3 |
| Paths | 4 |
| Total Lines | 70 |
| 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 |
||
| 49 | public function buildModelCriteria() |
||
| 50 | { |
||
| 51 | $query = parent::buildModelCriteria(); |
||
| 52 | |||
| 53 | if (null !== $featureTypeSlug = $this->getFeatureTypeSlug()) { |
||
| 54 | $featureTypeSlug = array_map(function($value) { |
||
| 55 | return "'" . addslashes($value) . "'"; |
||
| 56 | }, explode(',', $featureTypeSlug)); |
||
| 57 | |||
| 58 | $join = new Join(); |
||
| 59 | |||
| 60 | $join->addExplicitCondition( |
||
| 61 | FeatureTableMap::TABLE_NAME, |
||
| 62 | 'ID', |
||
| 63 | null, |
||
| 64 | FeatureFeatureTypeTableMap::TABLE_NAME, |
||
| 65 | 'FEATURE_ID', |
||
| 66 | null |
||
| 67 | ); |
||
| 68 | |||
| 69 | $join2 = new Join(); |
||
| 70 | |||
| 71 | $join2->addExplicitCondition( |
||
| 72 | FeatureFeatureTypeTableMap::TABLE_NAME, |
||
| 73 | 'FEATURE_TYPE_ID', |
||
| 74 | null, |
||
| 75 | FeatureTypeTableMap::TABLE_NAME, |
||
| 76 | 'ID', |
||
| 77 | null |
||
| 78 | ); |
||
| 79 | |||
| 80 | $join->setJoinType(Criteria::JOIN); |
||
| 81 | $join2->setJoinType(Criteria::JOIN); |
||
| 82 | |||
| 83 | $query |
||
| 84 | ->addJoinObject($join, 'feature_feature_type_join') |
||
| 85 | ->addJoinObject($join2, 'feature_type_join') |
||
| 86 | ->addJoinCondition( |
||
| 87 | 'feature_type_join', |
||
| 88 | '`feature_type`.`slug` IN ('.implode(',', $featureTypeSlug).')' |
||
| 89 | ); |
||
| 90 | } |
||
| 91 | |||
| 92 | if (null !== $featureTypeId = $this->getFeatureTypeId()) { |
||
| 93 | $join = new Join(); |
||
| 94 | |||
| 95 | $join->addExplicitCondition( |
||
| 96 | FeatureTableMap::TABLE_NAME, |
||
| 97 | 'ID', |
||
| 98 | null, |
||
| 99 | FeatureFeatureTypeTableMap::TABLE_NAME, |
||
| 100 | 'FEATURE_ID', |
||
| 101 | null |
||
| 102 | ); |
||
| 103 | |||
| 104 | $join->setJoinType(Criteria::JOIN); |
||
| 105 | |||
| 106 | $query |
||
| 107 | ->addJoinObject($join, 'feature_type_join') |
||
| 108 | ->addJoinCondition( |
||
| 109 | 'feature_type_join', |
||
| 110 | '`feature_feature_type`.`feature_type_id` IN (?)', |
||
| 111 | implode(',', $featureTypeId), |
||
| 112 | null, |
||
| 113 | \PDO::PARAM_INT |
||
| 114 | ); |
||
| 115 | } |
||
| 116 | |||
| 117 | return $query; |
||
| 118 | } |
||
| 119 | |||
| 223 |