| Conditions | 1 |
| Paths | 1 |
| Total Lines | 184 |
| Code Lines | 132 |
| 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 |
||
| 67 | public function buildForm() |
||
| 68 | { |
||
| 69 | $this |
||
| 70 | ->setAttr(['id' => 'firm-form', 'class' => 'submit-form', 'v-cloak' => 'v-cloak']) |
||
| 71 | ->setUrl(route('job.submit.firm')) |
||
| 72 | ->add('id', 'hidden', [ |
||
| 73 | 'rules' => 'sometimes|integer', |
||
| 74 | 'attr' => [ |
||
| 75 | 'v-model' => 'firm.id' |
||
| 76 | ] |
||
| 77 | ]) |
||
| 78 | ->add('is_private', 'choice', [ |
||
| 79 | 'multiple' => false, |
||
| 80 | 'rules' => 'boolean', |
||
| 81 | 'choices' => [ |
||
| 82 | true => 'Jestem osobą prywatną', |
||
| 83 | false => 'Reprezentuje firmę' |
||
| 84 | ], |
||
| 85 | 'child_attr' => [ |
||
| 86 | 'attr' => [ |
||
| 87 | 'v-model' => 'firm.is_private' |
||
| 88 | ] |
||
| 89 | ] |
||
| 90 | ]) |
||
| 91 | ->add('name', 'text', [ |
||
| 92 | 'rules' => 'required_if:is_private,0|max:60', |
||
| 93 | 'label' => 'Nazwa firmy', |
||
| 94 | 'help' => 'Podając nazwę firmy, oferta staje się bardziej wiarygodna i wartościowa.', |
||
| 95 | 'attr' => [ |
||
| 96 | 'v-model' => 'firm.name', |
||
| 97 | '@keydown.once' => 'changeFirm' |
||
| 98 | ] |
||
| 99 | ]) |
||
| 100 | ->add('is_agency', 'choice', [ |
||
| 101 | 'multiple' => false, |
||
| 102 | 'rules' => 'boolean', |
||
| 103 | 'choices' => [ |
||
| 104 | 0 => 'Bezpośredni pracodawca', |
||
| 105 | 1 => 'Agencja pośrednictwa / IT outsourcing' |
||
| 106 | ], |
||
| 107 | 'row_attr' => [ |
||
| 108 | 'class' => 'form-group-border' |
||
| 109 | ], |
||
| 110 | 'child_attr' => [ |
||
| 111 | 'attr' => [ |
||
| 112 | 'v-model' => 'firm.is_agency' |
||
| 113 | ] |
||
| 114 | ] |
||
| 115 | ]) |
||
| 116 | ->add('website', 'text', [ |
||
| 117 | 'rules' => 'url', |
||
| 118 | 'label' => 'Strona WWW', |
||
| 119 | 'help' => 'Firmowa strona WWW. Będzie ona wyświetlana przy ofercie.', |
||
| 120 | 'row_attr' => [ |
||
| 121 | 'class' => 'form-group-border', |
||
| 122 | ':class' => "{'has-error': isInvalid(['name'])}" |
||
| 123 | ], |
||
| 124 | 'attr' => [ |
||
| 125 | 'v-model' => 'firm.website' |
||
| 126 | ] |
||
| 127 | ]) |
||
| 128 | ->add('logo', 'hidden', [ |
||
| 129 | 'rules' => 'string', |
||
| 130 | 'attr' => [ |
||
| 131 | 'v-model' => 'firm.logo' |
||
| 132 | ] |
||
| 133 | ]) |
||
| 134 | ->add('description', 'textarea', [ |
||
| 135 | 'label' => 'Opis firmy', |
||
| 136 | 'rules' => 'string', |
||
| 137 | 'help' => 'Czym zajmuje się firma, w jakich branżach działa oraz jakie technologie wykorzystuje?', |
||
| 138 | 'attr' => [ |
||
| 139 | 'v-model' => 'firm.description' |
||
| 140 | ] |
||
| 141 | ]) |
||
| 142 | ->add('employees', 'select', [ |
||
| 143 | 'label' => 'Liczba pracowników w firmie', |
||
| 144 | 'rules' => 'integer', |
||
| 145 | 'help' => 'Pozwala ocenić jak duża jest firma. Czy jest to korporacja, czy mała rodzinna firma?', |
||
| 146 | 'choices' => Firm::getEmployeesList(), |
||
| 147 | 'empty_value' => '--', |
||
| 148 | 'row_attr' => [ |
||
| 149 | 'class' => 'form-group-border', |
||
| 150 | 'v-show' => 'firm.is_agency == 0' |
||
| 151 | ], |
||
| 152 | 'attr' => [ |
||
| 153 | 'v-model' => 'firm.employees' |
||
| 154 | ] |
||
| 155 | ]) |
||
| 156 | ->add('founded', 'select', [ |
||
| 157 | 'label' => 'Rok powstania', |
||
| 158 | 'help' => 'Pozwala ocenić jak duża jest firma. Czy jest to korporacja, czy mała rodzinna firma?', |
||
| 159 | 'rules' => 'integer', |
||
| 160 | 'choices' => Firm::getFoundedList(), |
||
| 161 | 'empty_value' => '--', |
||
| 162 | 'row_attr' => [ |
||
| 163 | 'class' => 'form-group-border', |
||
| 164 | ':class' => "{'has-error': isInvalid(['founded'])}", |
||
| 165 | 'v-show' => 'firm.is_agency == 0' |
||
| 166 | ], |
||
| 167 | 'attr' => [ |
||
| 168 | 'v-model' => 'firm.founded' |
||
| 169 | ] |
||
| 170 | ]) |
||
| 171 | ->add('headline', 'text', [ |
||
| 172 | 'rules' => 'string|max:100', |
||
| 173 | 'label' => 'Motto lub nagłówek', |
||
| 174 | 'help' => 'Pozostało <strong>${ charCounter(\'firm.headline\', 100) }</strong> znaków', |
||
| 175 | 'attr' => [ |
||
| 176 | 'maxlength' => 100, |
||
| 177 | 'v-model' => 'firm.headline' |
||
| 178 | ], |
||
| 179 | 'row_attr' => [ |
||
| 180 | ':class' => "{'has-error': isInvalid(['headline'])}", |
||
| 181 | 'v-show' => 'firm.is_agency == 0' |
||
| 182 | ] |
||
| 183 | ]) |
||
| 184 | ->add('latitude', 'hidden', [ |
||
| 185 | 'rules' => 'numeric', |
||
| 186 | 'attr' => [ |
||
| 187 | 'id' => 'latitude', |
||
| 188 | 'v-model' => 'firm.latitude' |
||
| 189 | ] |
||
| 190 | ]) |
||
| 191 | ->add('longitude', 'hidden', [ |
||
| 192 | 'rules' => 'numeric', |
||
| 193 | 'attr' => [ |
||
| 194 | 'id' => 'longitude', |
||
| 195 | 'v-model' => 'firm.longitude' |
||
| 196 | ] |
||
| 197 | ]) |
||
| 198 | ->add('street', 'hidden', [ |
||
| 199 | 'rules' => 'string|max:255', |
||
| 200 | 'attr' => [ |
||
| 201 | 'v-model' => 'firm.street' |
||
| 202 | ] |
||
| 203 | ]) |
||
| 204 | ->add('city', 'hidden', [ |
||
| 205 | 'rules' => 'string|max:255', |
||
| 206 | 'attr' => [ |
||
| 207 | 'v-model' => 'firm.city' |
||
| 208 | ] |
||
| 209 | ]) |
||
| 210 | ->add('country', 'hidden', [ |
||
| 211 | 'attr' => [ |
||
| 212 | 'v-model' => 'firm.country' |
||
| 213 | ] |
||
| 214 | ]) |
||
| 215 | ->add('postcode', 'hidden', [ |
||
| 216 | 'rules' => 'string|max:50', |
||
| 217 | 'attr' => [ |
||
| 218 | 'v-model' => 'firm.postcode' |
||
| 219 | ] |
||
| 220 | ]) |
||
| 221 | ->add('house', 'hidden', [ |
||
| 222 | 'rules' => 'string|max:50', |
||
| 223 | 'attr' => [ |
||
| 224 | 'v-model' => 'firm.house' |
||
| 225 | ] |
||
| 226 | ]) |
||
| 227 | ->add('address', 'text', [ |
||
| 228 | 'label' => 'Adres', |
||
| 229 | 'help' => 'Wpisz adres i naciśnij Enter lub kliknij na mapę. Adres firmy będzie wyświetlany przy ofercie.', |
||
| 230 | 'attr' => [ |
||
| 231 | 'id' => 'address', |
||
| 232 | 'v-model' => 'address', |
||
| 233 | '@keydown.enter.prevent' => 'changeAddress' |
||
| 234 | ] |
||
| 235 | ]) |
||
| 236 | ->add('benefits', 'collection', [ |
||
| 237 | 'property' => 'name', |
||
| 238 | 'child_attr' => [ |
||
| 239 | 'type' => 'text' |
||
| 240 | ] |
||
| 241 | ]) |
||
| 242 | ->add('submit', 'submit', [ |
||
| 243 | 'label' => 'Zapisz', |
||
| 244 | 'attr' => [ |
||
| 245 | 'data-submit-state' => 'Wysyłanie...' |
||
| 246 | ] |
||
| 247 | ]); |
||
| 248 | |||
| 249 | $this->setDefaultOptions(); |
||
| 250 | } |
||
| 251 | |||
| 292 |
PHP Analyzer performs a side-effects analysis of your code. A side-effect is basically anything that might be visible after the scope of the method is left.
Let’s take a look at an example:
If we look at the
getEmail()method, we can see that it has no side-effect. Whether you call this method or not, no future calls to other methods are affected by this. As such code as the following is useless:On the hand, if we look at the
setEmail(), this method _has_ side-effects. In the following case, we could not remove the method call: