| Conditions | 10 |
| Paths | 384 |
| Total Lines | 37 |
| Code Lines | 21 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | 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 |
||
| 104 | protected function hydrateObjectArray($data, $locale = null) |
||
|
|
|||
| 105 | { |
||
| 106 | $model = new DealerShedules(); |
||
| 107 | |||
| 108 | if (isset($data['id'])) { |
||
| 109 | $dealer = DealerShedulesQuery::create()->findOneById($data['id']); |
||
| 110 | if ($dealer) { |
||
| 111 | $model = $dealer; |
||
| 112 | } |
||
| 113 | } |
||
| 114 | |||
| 115 | // Require Field |
||
| 116 | if (isset($data['day'])) { |
||
| 117 | $model->setDay($data['day']); |
||
| 118 | } |
||
| 119 | if (isset($data['begin'])) { |
||
| 120 | $model->setBegin($data['begin']); |
||
| 121 | } |
||
| 122 | if (isset($data['end'])) { |
||
| 123 | $model->setEnd($data['end']); |
||
| 124 | } |
||
| 125 | if (isset($data['period_begin'])) { |
||
| 126 | $model->setPeriodBegin($data['period_begin']); |
||
| 127 | } |
||
| 128 | if (isset($data['period_end'])) { |
||
| 129 | $model->setPeriodEnd($data['period_end']); |
||
| 130 | } |
||
| 131 | if (isset($data['dealer_id'])) { |
||
| 132 | $model->setDealerId($data['dealer_id']); |
||
| 133 | } |
||
| 134 | if (isset($data['closed'])) { |
||
| 135 | $model->setClosed($data['closed']); |
||
| 136 | } |
||
| 137 | |||
| 138 | |||
| 139 | return $model; |
||
| 140 | } |
||
| 141 | } |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.