| Conditions | 1 |
| Paths | 1 |
| Total Lines | 53 |
| Code Lines | 37 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| Bugs | 3 | Features | 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 |
||
| 29 | public function init() |
||
| 30 | { |
||
| 31 | $this->add([ |
||
| 32 | 'name' => 'logmessage', |
||
| 33 | 'type' => 'Textarea', |
||
| 34 | 'options' => [ |
||
| 35 | 'label' => 'Log message', |
||
| 36 | ], |
||
| 37 | 'attributes' => [ |
||
| 38 | 'value' => 'this is log message', |
||
| 39 | ], |
||
| 40 | ]); |
||
| 41 | |||
| 42 | $this->add([ |
||
| 43 | 'name' => 'logpriority', |
||
| 44 | 'type' => 'Select', |
||
| 45 | 'options' => [ |
||
| 46 | 'value_options' => [ |
||
| 47 | 0 => 'EMERG', |
||
| 48 | 1 => 'ALERT', |
||
| 49 | 2 => 'CRIT', |
||
| 50 | 3 => 'ERR', |
||
| 51 | 4 => 'WARN', |
||
| 52 | 5 => 'NOTICE', |
||
| 53 | 6 => 'INFO', |
||
| 54 | 7 => 'DEBUG', |
||
| 55 | ], |
||
| 56 | 'label' => 'Log priority', |
||
| 57 | ], |
||
| 58 | ]); |
||
| 59 | |||
| 60 | $this->add([ |
||
| 61 | 'name' => 'logformat', |
||
| 62 | 'type' => 'Select', |
||
| 63 | 'options' => [ |
||
| 64 | 'value_options' => [ |
||
| 65 | 'simple' => 'Simple', |
||
| 66 | 'xml' => 'Xml', |
||
| 67 | ], |
||
| 68 | 'label' => 'Log format', |
||
| 69 | ], |
||
| 70 | ]); |
||
| 71 | |||
| 72 | $this->add([ |
||
| 73 | 'name' => 'submit', |
||
| 74 | 'attributes' => [ |
||
| 75 | 'class' => 'form-control btn-primary', |
||
| 76 | 'type' => 'submit', |
||
| 77 | 'value' => 'Submit log data', |
||
| 78 | 'id' => 'submitbutton', |
||
| 79 | ], |
||
| 80 | ]); |
||
| 81 | } |
||
| 82 | |||
| 103 |