| Conditions | 1 |
| Paths | 1 |
| Total Lines | 68 |
| Code Lines | 41 |
| 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 |
||
| 8 | public function __construct(array $strings) |
||
| 9 | { |
||
| 10 | parent::__construct('rbcomment'); |
||
| 11 | |||
| 12 | $this->setAttributes([ |
||
| 13 | 'method' => 'post', |
||
| 14 | 'action' => '/rbcomment/add', |
||
| 15 | ]); |
||
| 16 | |||
| 17 | $this->add([ |
||
| 18 | 'type' => 'Csrf', |
||
| 19 | 'name' => 'csrf', |
||
| 20 | ]); |
||
| 21 | |||
| 22 | $this->add([ |
||
| 23 | 'name' => 'id', |
||
| 24 | 'attributes' => [ |
||
| 25 | 'type' => 'hidden', |
||
| 26 | ], |
||
| 27 | ]); |
||
| 28 | |||
| 29 | $this->add([ |
||
| 30 | 'name' => 'thread', |
||
| 31 | 'attributes' => [ |
||
| 32 | 'type' => 'hidden', |
||
| 33 | ], |
||
| 34 | ]); |
||
| 35 | |||
| 36 | $this->add([ |
||
| 37 | 'name' => 'uri', |
||
| 38 | 'attributes' => [ |
||
| 39 | 'type' => 'hidden', |
||
| 40 | ], |
||
| 41 | ]); |
||
| 42 | |||
| 43 | $this->add([ |
||
| 44 | 'name' => 'author', |
||
| 45 | 'attributes' => [ |
||
| 46 | 'type' => 'text', |
||
| 47 | 'placeholder' => $strings['author'], |
||
| 48 | ], |
||
| 49 | ]); |
||
| 50 | |||
| 51 | $this->add([ |
||
| 52 | 'name' => 'contact', |
||
| 53 | 'attributes' => [ |
||
| 54 | 'type' => 'text', |
||
| 55 | 'placeholder' => $strings['contact'], |
||
| 56 | ], |
||
| 57 | ]); |
||
| 58 | |||
| 59 | $this->add([ |
||
| 60 | 'type' => 'Textarea', |
||
| 61 | 'name' => 'content', |
||
| 62 | 'attributes' => [ |
||
| 63 | 'placeholder' => $strings['content'], |
||
| 64 | ], |
||
| 65 | ]); |
||
| 66 | |||
| 67 | $this->add([ |
||
| 68 | 'name' => 'submit', |
||
| 69 | 'attributes' => [ |
||
| 70 | 'type' => 'submit', |
||
| 71 | 'value' => $strings['submit'], |
||
| 72 | 'id' => 'submitbutton', |
||
| 73 | ], |
||
| 74 | ]); |
||
| 75 | } |
||
| 76 | } |
||
| 77 |