Conditions | 10 |
Paths | 32 |
Total Lines | 47 |
Code Lines | 32 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 |
||
80 | public function buildModelCriteria() |
||
81 | { |
||
82 | $search = ResourceQuery::create(); |
||
83 | |||
84 | /* manage translations */ |
||
85 | $this->configureI18nProcessing($search); |
||
86 | |||
87 | $profile = $this->getProfile(); |
||
88 | |||
89 | if (null !== $profile) { |
||
|
|||
90 | $search->leftJoinProfileResource('profile_resource') |
||
91 | ->addJoinCondition('profile_resource', 'profile_resource.PROFILE_ID=?', $profile, null, \PDO::PARAM_INT) |
||
92 | ->withColumn('profile_resource.access', 'access'); |
||
93 | } |
||
94 | |||
95 | $code = $this->getCode(); |
||
96 | |||
97 | if (null !== $code) { |
||
98 | $search->filterByCode($code, Criteria::IN); |
||
99 | } |
||
100 | |||
101 | $orders = $this->getOrder(); |
||
102 | |||
103 | foreach ($orders as $order) { |
||
104 | switch ($order) { |
||
105 | case "id": |
||
106 | $search->orderById(Criteria::ASC); |
||
107 | break; |
||
108 | case "id_reverse": |
||
109 | $search->orderById(Criteria::DESC); |
||
110 | break; |
||
111 | case "title": |
||
112 | $search->addAscendingOrderByColumn('i18n_TITLE'); |
||
113 | break; |
||
114 | case "title_reverse": |
||
115 | $search->addDescendingOrderByColumn('i18n_TITLE'); |
||
116 | break; |
||
117 | case "code": |
||
118 | $search->orderByCode(Criteria::ASC); |
||
119 | break; |
||
120 | case "code_reverse": |
||
121 | $search->orderByCode(Criteria::DESC); |
||
122 | break; |
||
123 | } |
||
124 | } |
||
125 | |||
126 | return $search; |
||
127 | } |
||
167 |