| Conditions | 1 |
| Paths | 1 |
| Total Lines | 86 |
| Code Lines | 73 |
| 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 |
||
| 109 | public function createComponentRegistrationForm(): Form |
||
| 110 | { |
||
| 111 | $provinces = $this->getProvinceModel()->all(); |
||
| 112 | |||
| 113 | $form = new Form; |
||
| 114 | |||
| 115 | $form->addText('name', 'Jméno:') |
||
| 116 | ->setRequired(static::MESSAGE_REQUIRED) |
||
| 117 | ->addRule(Form::MAX_LENGTH, static::MESSAGE_MAX_LENGTH, 20) |
||
| 118 | ->getLabelPrototype()->setAttribute('class', 'required'); |
||
| 119 | $form->addText('surname', 'Příjmení:') |
||
| 120 | ->setRequired(static::MESSAGE_REQUIRED) |
||
| 121 | ->addRule(Form::MAX_LENGTH, static::MESSAGE_MAX_LENGTH, 30) |
||
| 122 | ->getLabelPrototype()->setAttribute('class', 'required'); |
||
| 123 | $form->addText('nick', 'Přezdívka:') |
||
| 124 | ->setRequired(static::MESSAGE_REQUIRED) |
||
| 125 | ->addRule(Form::MAX_LENGTH, static::MESSAGE_MAX_LENGTH, 20) |
||
| 126 | ->getLabelPrototype()->setAttribute('class', 'required'); |
||
| 127 | $form->addEmail('email', 'E-mail:') |
||
| 128 | ->setRequired(static::MESSAGE_REQUIRED) |
||
| 129 | ->getLabelPrototype()->setAttribute('class', 'required'); |
||
| 130 | $form->addTbDatePicker('birthday', 'Datum narození:', null, 16) |
||
| 131 | ->setRequired(static::MESSAGE_REQUIRED) |
||
| 132 | ->setFormat('d. m. Y') |
||
| 133 | ->setAttribute('placeholder', 'dd. mm. rrrr') |
||
| 134 | ->getLabelPrototype()->setAttribute('class', 'required'); |
||
| 135 | $form->addText('street', 'Ulice:') |
||
| 136 | ->setRequired(static::MESSAGE_REQUIRED) |
||
| 137 | ->addRule(Form::MAX_LENGTH, static::MESSAGE_MAX_LENGTH, 30) |
||
| 138 | ->getLabelPrototype()->setAttribute('class', 'required'); |
||
| 139 | $form->addText('city', 'Město:') |
||
| 140 | ->setRequired(static::MESSAGE_REQUIRED) |
||
| 141 | ->addRule(Form::MAX_LENGTH, static::MESSAGE_MAX_LENGTH, 64) |
||
| 142 | ->getLabelPrototype()->setAttribute('class', 'required'); |
||
| 143 | $form->addText('postal_code', 'PSČ:') |
||
| 144 | ->setRequired(static::MESSAGE_REQUIRED) |
||
| 145 | ->addRule(Form::PATTERN, 'Číslo musí být ve formátu nnnnn!', '[1-9]{1}[0-9]{4}') |
||
| 146 | ->setAttribute('placeholder', '12345') |
||
| 147 | ->getLabelPrototype()->setAttribute('class', 'required'); |
||
| 148 | $form->addText('group_num', 'Číslo středika/přístavu:') |
||
| 149 | ->setRequired(static::MESSAGE_REQUIRED) |
||
| 150 | ->addRule(Form::PATTERN, 'Číslo musí být ve formátu nnn.nn!', '[1-9]{1}[0-9a-zA-Z]{2}\.[0-9a-zA-Z]{1}[0-9a-zA-Z]{1}') |
||
| 151 | ->setAttribute('placeholder', '214.02') |
||
| 152 | ->getLabelPrototype()->setAttribute('class', 'required'); |
||
| 153 | $form->addText('group_name', 'Název střediska/přístavu:') |
||
| 154 | ->setRequired(static::MESSAGE_REQUIRED) |
||
| 155 | ->addRule(Form::MAX_LENGTH, static::MESSAGE_MAX_LENGTH, 50) |
||
| 156 | ->setAttribute('placeholder', '2. přístav Poutníci Kolín') |
||
| 157 | ->getLabelPrototype()->setAttribute('class', 'required'); |
||
| 158 | $form->addText('troop_name', 'Název oddílu:') |
||
| 159 | ->setAttribute('placeholder', '22. oddíl Galeje') |
||
| 160 | ->addCondition(Form::FILLED, true) |
||
| 161 | ->addRule(Form::MAX_LENGTH, static::MESSAGE_MAX_LENGTH, 50); |
||
| 162 | |||
| 163 | $form->addSelect('province', 'Kraj:', $provinces) |
||
| 164 | ->setPrompt('zvolte kraj'); |
||
| 165 | |||
| 166 | $form = $this->buildMealSwitcher($form); |
||
| 167 | |||
| 168 | $form->addTextArea('arrival', 'Informace o příjezdu:') |
||
| 169 | ->setAttribute('placeholder', 'Napište, prosím, stručně jakým dopravním prostředkem a v kolik hodin (přibližně) přijedete na místo srazu.'); |
||
| 170 | $form->addTextArea('departure', 'Informace o odjezdu:') |
||
| 171 | ->setAttribute('placeholder', 'Napište, prosím, stručně jakým dopravním prostředkem a v kolik hodin (přibližně) sraz opustíte.'); |
||
| 172 | $form->addTextArea('comment', 'Dotazy, přání, připomínky, stížnosti:'); |
||
| 173 | $form->addTextArea('question', 'Vaše nabídka:') |
||
| 174 | ->setAttribute('placeholder', 'Vaše nabídka na sdílení dobré praxe (co u vás umíte dobře a jste ochotni se o to podělit)'); |
||
| 175 | $form->addTextArea('question2', 'Počet a typy lodí:') |
||
| 176 | ->setAttribute('placeholder', 'Počet a typy lodí, které sebou přivezete (vyplňte pokud ano)'); |
||
| 177 | |||
| 178 | $form = $this->buildProgramSwitcher($form); |
||
| 179 | |||
| 180 | $form->addHidden('mid', $this->getMeetingId()); |
||
| 181 | $form->addHidden('bill', 0); |
||
| 182 | $form->addHidden('cost', $this->getMeetingModel()->getPrice('cost')); |
||
| 183 | |||
| 184 | $form->addSubmit('save', 'Uložit') |
||
| 185 | ->setAttribute('class', 'btn-primary'); |
||
| 186 | $form->addSubmit('reset', 'storno') |
||
| 187 | ->setAttribute('class', 'btn-reset'); |
||
| 188 | |||
| 189 | $form = $this->setupRendering($form); |
||
| 190 | |||
| 191 | $form->onSuccess[] = [$this, 'processForm']; |
||
| 192 | |||
| 193 | return $form; |
||
| 194 | } |
||
| 195 | |||
| 456 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.