| Conditions | 1 |
| Paths | 1 |
| Total Lines | 57 |
| Code Lines | 32 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 1 |
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 |
||
| 37 | public function init() |
||
| 38 | { |
||
| 39 | $this->setName('contact'); |
||
| 40 | |||
| 41 | $this->add( |
||
| 42 | array( |
||
| 43 | 'name' => 'street', |
||
| 44 | 'options' => array( |
||
| 45 | 'label' => /* @translate */ 'street' |
||
| 46 | ) |
||
| 47 | ) |
||
| 48 | ); |
||
| 49 | |||
| 50 | $this->add( |
||
| 51 | array( |
||
| 52 | 'name' => 'houseNumber', |
||
| 53 | 'options' => array( |
||
| 54 | 'label' => /* @translate */ 'house number' |
||
| 55 | ) |
||
| 56 | ) |
||
| 57 | ); |
||
| 58 | |||
| 59 | $this->add( |
||
| 60 | array( |
||
| 61 | 'name' => 'postalcode', |
||
| 62 | 'options' => array( |
||
| 63 | 'label' => /* @translate */ 'Postalcode' |
||
| 64 | ) |
||
| 65 | ) |
||
| 66 | ); |
||
| 67 | |||
| 68 | $this->add( |
||
| 69 | array( |
||
| 70 | 'name' => 'city', |
||
| 71 | 'options' => array( |
||
| 72 | 'label' => /* @translate */ 'City' |
||
| 73 | ) |
||
| 74 | ) |
||
| 75 | ); |
||
| 76 | $this->add( |
||
| 77 | array( |
||
| 78 | 'name' => 'phone', |
||
| 79 | 'options' => array( |
||
| 80 | 'label' => /* @translate */ 'Phone' |
||
| 81 | ) |
||
| 82 | ) |
||
| 83 | ); |
||
| 84 | $this->add( |
||
| 85 | array( |
||
| 86 | 'name' => 'fax', |
||
| 87 | 'options' => array( |
||
| 88 | 'label' => /* @translate */ 'Fax' |
||
| 89 | ) |
||
| 90 | ) |
||
| 91 | ); |
||
| 92 | |||
| 93 | } |
||
| 94 | |||
| 114 |