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 |
||
85 | public function buildModelCriteria() |
||
86 | { |
||
87 | $query = new AttributeTypeQuery(); |
||
88 | |||
89 | /* manage translations */ |
||
90 | $this->configureI18nProcessing($query, array('TITLE', 'DESCRIPTION')); |
||
91 | |||
92 | if (null !== $id = $this->getId()) { |
||
93 | $query->filterById($id); |
||
94 | } |
||
95 | |||
96 | if (null !== $id = $this->getExcludeId()) { |
||
97 | $query->filterById($id, Criteria::NOT_IN); |
||
98 | } |
||
99 | |||
100 | if (null !== $slug = $this->getSlug()) { |
||
101 | $query->filterBySlug($slug); |
||
102 | } |
||
103 | |||
104 | if (null !== $attributeId = $this->getAttributeId()) { |
||
105 | $join = new Join(); |
||
106 | |||
107 | $join->addExplicitCondition( |
||
108 | AttributeTypeTableMap::TABLE_NAME, |
||
109 | 'ID', |
||
110 | null, |
||
111 | AttributeAttributeTypeTableMap::TABLE_NAME, |
||
112 | 'ATTRIBUTE_TYPE_ID', |
||
113 | null |
||
114 | ); |
||
115 | |||
116 | $join->setJoinType(Criteria::JOIN); |
||
117 | |||
118 | $query |
||
119 | ->addJoinObject($join, 'attribute_type_join') |
||
120 | ->addJoinCondition( |
||
121 | 'attribute_type_join', |
||
122 | '`attribute_attribute_type`.`attribute_id` IN (?)', |
||
123 | implode(',', $attributeId), |
||
124 | null, |
||
125 | \PDO::PARAM_INT |
||
126 | ); |
||
127 | } |
||
128 | |||
129 | foreach ($this->getOrder() as $order) { |
||
130 | switch ($order) { |
||
131 | case "id": |
||
132 | $query->orderById(); |
||
133 | break; |
||
134 | case "id-reverse": |
||
135 | $query->orderById(Criteria::DESC); |
||
136 | break; |
||
137 | case "slug": |
||
138 | $query->orderBySlug(); |
||
139 | break; |
||
140 | case "slug-reverse": |
||
141 | $query->orderBySlug(Criteria::DESC); |
||
142 | break; |
||
143 | } |
||
144 | } |
||
145 | return $query; |
||
146 | } |
||
147 | |||
184 |