| Conditions | 16 |
| Paths | > 20000 |
| Total Lines | 76 |
| 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 |
||
| 105 | protected function hydrateObjectArray($data, $locale = null) |
||
| 106 | { |
||
| 107 | $model = new Dealer(); |
||
| 108 | |||
| 109 | if (isset($data['id'])) { |
||
| 110 | $dealer = DealerQuery::create()->findOneById($data['id']); |
||
| 111 | if ($dealer) { |
||
| 112 | $model = $dealer; |
||
| 113 | } |
||
| 114 | } |
||
| 115 | |||
| 116 | if ($locale) { |
||
| 117 | $model->setLocale($locale); |
||
| 118 | } |
||
| 119 | |||
| 120 | // Require Field |
||
| 121 | if (isset($data['title'])) { |
||
| 122 | $model->setTitle($data['title']); |
||
| 123 | } |
||
| 124 | if (isset($data['address1'])) { |
||
| 125 | $model->setAddress1($data['address1']); |
||
| 126 | } |
||
| 127 | if (isset($data['zipcode'])) { |
||
| 128 | $model->setZipcode($data['zipcode']); |
||
| 129 | } |
||
| 130 | if (isset($data['city'])) { |
||
| 131 | $model->setCity($data['city']); |
||
| 132 | } |
||
| 133 | if (isset($data['country_id'])) { |
||
| 134 | $model->setCountryId($data['country_id']); |
||
| 135 | } |
||
| 136 | if (isset($data['visible'])) { |
||
| 137 | $model->setVisible($data['visible']); |
||
| 138 | } |
||
| 139 | |||
| 140 | // Optionnal Field |
||
| 141 | if (isset($data['description'])) { |
||
| 142 | $model->setDescription($data['description']); |
||
| 143 | } else { |
||
| 144 | $model->setDescription(null); |
||
| 145 | } |
||
| 146 | |||
| 147 | // Optionnal Field |
||
| 148 | if (isset($data['big_description'])) { |
||
| 149 | $model->setBigDescription($data['big_description']); |
||
| 150 | } else { |
||
| 151 | $model->setBigDescription(null); |
||
| 152 | } |
||
| 153 | |||
| 154 | // Optionnal Field |
||
| 155 | if (isset($data['hard_open_hour'])) { |
||
| 156 | $model->setHardOpenHour($data['hard_open_hour']); |
||
| 157 | } else { |
||
| 158 | $model->setHardOpenHour(null); |
||
| 159 | } |
||
| 160 | |||
| 161 | if (isset($data['access'])) { |
||
| 162 | $model->setAccess($data['access']); |
||
| 163 | } else { |
||
| 164 | $model->setAccess(null); |
||
| 165 | } |
||
| 166 | |||
| 167 | if (isset($data['address2'])) { |
||
| 168 | $model->setAddress2($data['address2']); |
||
| 169 | } else { |
||
| 170 | $model->setAddress2(null); |
||
| 171 | } |
||
| 172 | |||
| 173 | if (isset($data['address3'])) { |
||
| 174 | $model->setAddress3($data['address3']); |
||
| 175 | } else { |
||
| 176 | $model->setAddress3(null); |
||
| 177 | } |
||
| 178 | |||
| 179 | return $model; |
||
| 180 | } |
||
| 181 | } |
||
| 182 |