| Conditions | 14 |
| Paths | 6144 |
| Total Lines | 62 |
| Code Lines | 37 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 4 | ||
| Bugs | 1 | Features | 2 |
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 | if (isset($data['access'])) { |
||
| 148 | $model->setAccess($data['access']); |
||
| 149 | } else { |
||
| 150 | $model->setAccess(null); |
||
| 151 | } |
||
| 152 | |||
| 153 | if (isset($data['address2'])) { |
||
| 154 | $model->setAddress2($data['address2']); |
||
| 155 | } else { |
||
| 156 | $model->setAddress2(null); |
||
| 157 | } |
||
| 158 | |||
| 159 | if (isset($data['address3'])) { |
||
| 160 | $model->setAddress3($data['address3']); |
||
| 161 | } else { |
||
| 162 | $model->setAddress3(null); |
||
| 163 | } |
||
| 164 | |||
| 165 | return $model; |
||
| 166 | } |
||
| 167 | |||
| 168 | } |