Conditions | 1 |
Paths | 1 |
Total Lines | 52 |
Code Lines | 37 |
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 |
||
40 | protected function init() : void |
||
41 | { |
||
42 | $this->initAdapter(); |
||
43 | |||
44 | $name = $this->createElement( |
||
45 | HtmlElement::class, |
||
46 | HtmlElement::HTML_ELEMENT_INPUT_TEXT, |
||
47 | 'name', |
||
48 | 'Application name' |
||
49 | ); |
||
50 | |||
51 | $title = $this->createElement( |
||
52 | HtmlElement::class, |
||
53 | HtmlElement::HTML_ELEMENT_INPUT_TEXT, |
||
54 | 'title', |
||
55 | 'Display name (title)' |
||
56 | ); |
||
57 | |||
58 | $introduction = $this->createElement( |
||
59 | HtmlElement::class, |
||
60 | HtmlElement::HTML_ELEMENT_TEXTAREA, |
||
61 | 'introduction', |
||
62 | 'Introduction' |
||
63 | ); |
||
64 | |||
65 | $subject = $this->createElement( |
||
66 | HtmlElement::class, |
||
67 | HtmlElement::HTML_ELEMENT_TEXTAREA, |
||
68 | 'subject', |
||
69 | 'Subject' |
||
70 | ); |
||
71 | |||
72 | $description = $this->createElement( |
||
73 | HtmlElement::class, |
||
74 | HtmlElement::HTML_ELEMENT_TEXTAREA, |
||
75 | 'description', |
||
76 | 'Description' |
||
77 | ); |
||
78 | |||
79 | $submit = $this->createElement( |
||
80 | HtmlElement::class, |
||
81 | HtmlElement::HTML_ELEMENT_SUBMIT, |
||
82 | 'submit', |
||
83 | 'Save' |
||
84 | ); |
||
85 | |||
86 | $this->formAdapter->addElement($name) |
||
87 | ->addElement($title) |
||
88 | ->addElement($introduction) |
||
89 | ->addElement($subject) |
||
90 | ->addElement($description) |
||
91 | ->addElement($submit); |
||
92 | } |
||
94 |