| Conditions | 10 |
| Paths | 56 |
| Total Lines | 51 |
| 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 |
||
| 106 | public function buildModelCriteria() |
||
| 107 | { |
||
| 108 | $query = DealerContactQuery::create(); |
||
| 109 | |||
| 110 | // manage translations |
||
| 111 | $this->configureI18nProcessing( |
||
| 112 | $query, |
||
| 113 | [ |
||
| 114 | 'LABEL', |
||
| 115 | ], |
||
| 116 | null, |
||
| 117 | 'ID', |
||
| 118 | $this->getForceReturn() |
||
| 119 | ); |
||
| 120 | |||
| 121 | if (null != $default = $this->getDefault()) { |
||
| 122 | $query->filterByIsDefault($default); |
||
| 123 | } |
||
| 124 | |||
| 125 | if ($id = $this->getId()) { |
||
| 126 | $query->filterById($id); |
||
| 127 | } |
||
| 128 | |||
| 129 | if ($dealer_id = $this->getDealerId()) { |
||
| 130 | $query->filterByDealerId($dealer_id); |
||
| 131 | } |
||
| 132 | |||
| 133 | foreach ($this->getOrder() as $order) { |
||
| 134 | switch ($order) { |
||
| 135 | case 'id': |
||
| 136 | $query->orderById(); |
||
| 137 | break; |
||
| 138 | case 'id-reverse': |
||
| 139 | $query->orderById(Criteria::DESC); |
||
| 140 | break; |
||
| 141 | case 'label': |
||
| 142 | $query->orderByLabel(); |
||
| 143 | break; |
||
| 144 | case 'label-reverse': |
||
| 145 | $query->orderByLabel(Criteria::DESC); |
||
| 146 | break; |
||
| 147 | case 'default-first': |
||
| 148 | $query->orderByIsDefault(Criteria::DESC); |
||
| 149 | break; |
||
| 150 | default: |
||
| 151 | break; |
||
| 152 | } |
||
| 153 | } |
||
| 154 | |||
| 155 | return $query; |
||
| 156 | } |
||
| 157 | } |
||
| 158 |