Conditions | 1 |
Paths | 1 |
Total Lines | 96 |
Code Lines | 60 |
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 |
||
44 | public function addElements() |
||
45 | { |
||
46 | |||
47 | $this->setHydrator(new DoctrineHydrator($this->objectManager, 'JhFlexiTime\Entity\Booking')) |
||
|
|||
48 | ->setObject(new Booking()); |
||
49 | |||
50 | $this->add([ |
||
51 | 'type' => 'Zend\Form\Element\Hidden', |
||
52 | 'name' => 'user', |
||
53 | 'attributes' => [ |
||
54 | 'id' => 'book-user', |
||
55 | 'value' => $this->user->getId(), |
||
56 | ] |
||
57 | ]); |
||
58 | |||
59 | $this->add([ |
||
60 | 'type' => 'Zend\Form\Element\Hidden', |
||
61 | 'name' => 'id', |
||
62 | 'attributes' => [ |
||
63 | 'id' => 'book-id', |
||
64 | ] |
||
65 | ]); |
||
66 | |||
67 | $this->add([ |
||
68 | 'type' => 'Zend\Form\Element\Text', |
||
69 | 'name' => 'date', |
||
70 | 'options' => [ |
||
71 | 'label' => 'Date', |
||
72 | 'label_attributes' => [ |
||
73 | 'class' => 'col-sm-4 control-label', |
||
74 | ], |
||
75 | ], |
||
76 | 'attributes' => [ |
||
77 | 'id' => 'book-date', |
||
78 | 'step' => '1', |
||
79 | 'required' => 'required', |
||
80 | 'class' => 'form-control input-sm', |
||
81 | //'value' => new \DateTime(), |
||
82 | ], |
||
83 | ]); |
||
84 | |||
85 | $this->add([ |
||
86 | 'type' => 'Zend\Form\Element\Time', |
||
87 | 'name' => 'startTime', |
||
88 | 'options' => [ |
||
89 | 'label' => 'Start Time', |
||
90 | 'label_attributes' => [ |
||
91 | 'class' => 'col-sm-4 control-label', |
||
92 | ], |
||
93 | ], |
||
94 | 'attributes' => [ |
||
95 | 'id' => 'book-starttime', |
||
96 | //TODO: Inject From options |
||
97 | //'min' => '07:00:00', |
||
98 | //'max' => '10:00:00', |
||
99 | 'step' => '900', //15 mins, 60 x 15 |
||
100 | 'class' => 'form-control input-sm', |
||
101 | 'value' => '07:00', |
||
102 | ], |
||
103 | ]); |
||
104 | |||
105 | $this->add([ |
||
106 | 'type' => 'Zend\Form\Element\Time', |
||
107 | 'name' => 'endTime', |
||
108 | 'options' => [ |
||
109 | 'label' => 'End Time', |
||
110 | 'label_attributes' => [ |
||
111 | 'class' => 'col-sm-4 control-label', |
||
112 | ], |
||
113 | ], |
||
114 | 'attributes' => [ |
||
115 | 'id' => 'book-endtime', |
||
116 | //TODO: Inject From options |
||
117 | //'min' => '16:00:00', |
||
118 | //'max' => '19:00:00', |
||
119 | 'step' => '900', //15 mins, 60 x 15 |
||
120 | 'class' => 'form-control input-sm', |
||
121 | 'value' => '16:00', |
||
122 | ], |
||
123 | ]); |
||
124 | |||
125 | $this->add([ |
||
126 | 'type' => 'Zend\Form\Element\Textarea', |
||
127 | 'name' => 'notes', |
||
128 | 'options' => [ |
||
129 | 'label' => 'Notes', |
||
130 | 'label_attributes' => [ |
||
131 | 'class' => 'col-sm-4 control-label', |
||
132 | ], |
||
133 | ], |
||
134 | 'attributes' => [ |
||
135 | 'id' => 'book-notes', |
||
136 | 'class' => 'form-control input-sm', |
||
137 | ] |
||
138 | ]); |
||
139 | } |
||
140 | } |
||
141 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: