| Conditions | 2 | 
| Paths | 1 | 
| Total Lines | 117 | 
| Code Lines | 90 | 
| 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  | 
            ||
| 172 | public function setupUpdateOperation()  | 
            ||
| 173 |     { | 
            ||
| 174 | $this->crud->addField([  | 
            ||
| 175 | 'name' => 'title',  | 
            ||
| 176 | 'label' => 'Title',  | 
            ||
| 177 | 'type' => 'text',  | 
            ||
| 178 | 'attributes' => [  | 
            ||
| 179 | 'readonly' => 'readonly'  | 
            ||
| 180 | ]  | 
            ||
| 181 | ]);  | 
            ||
| 182 | $this->crud->addField([  | 
            ||
| 183 | 'name' => 'salary_min',  | 
            ||
| 184 | 'type' => 'number',  | 
            ||
| 185 | 'label' => 'Minimum Salary',  | 
            ||
| 186 | ]);  | 
            ||
| 187 | $this->crud->addField([  | 
            ||
| 188 | 'name' => 'salary_max',  | 
            ||
| 189 | 'type' => 'number',  | 
            ||
| 190 | 'label' => 'Maximum Salary',  | 
            ||
| 191 | ]);  | 
            ||
| 192 | $this->crud->addField([  | 
            ||
| 193 | 'name' => 'noc',  | 
            ||
| 194 | 'type' => 'number',  | 
            ||
| 195 | 'label' => 'NOC Code',  | 
            ||
| 196 | ]);  | 
            ||
| 197 | $this->crud->addField([  | 
            ||
| 198 | 'name' => 'open_date_time',  | 
            ||
| 199 | 'label' => 'Open Date',  | 
            ||
| 200 | 'type' => 'date_picker',  | 
            ||
| 201 | 'date_picker_options' => [  | 
            ||
| 202 | 'todayBtn' => 'linked',  | 
            ||
| 203 | 'format' => 'yyyy-mm-dd',  | 
            ||
| 204 | ],  | 
            ||
| 205 | ]);  | 
            ||
| 206 | $this->crud->addField([  | 
            ||
| 207 | 'name' => 'close_date_time',  | 
            ||
| 208 | 'label' => 'Close Date',  | 
            ||
| 209 | 'type' => 'date_picker',  | 
            ||
| 210 | 'date_picker_options' => [  | 
            ||
| 211 | 'todayBtn' => 'linked',  | 
            ||
| 212 | 'format' => 'yyyy-mm-dd',  | 
            ||
| 213 | ],  | 
            ||
| 214 | ]);  | 
            ||
| 215 | $this->crud->addField([  | 
            ||
| 216 | 'name' => 'start_date_time',  | 
            ||
| 217 | 'label' => 'Start Date',  | 
            ||
| 218 | 'type' => 'date_picker',  | 
            ||
| 219 | 'date_picker_options' => [  | 
            ||
| 220 | 'todayBtn' => 'linked',  | 
            ||
| 221 | 'format' => 'yyyy-mm-dd',  | 
            ||
| 222 | ],  | 
            ||
| 223 | ]);  | 
            ||
| 224 | $this->crud->addField([  | 
            ||
| 225 | 'name' => 'process_number',  | 
            ||
| 226 | 'type' => 'text',  | 
            ||
| 227 | 'label' => 'Process #',  | 
            ||
| 228 | ]);  | 
            ||
| 229 | $this->crud->addField([  | 
            ||
| 230 | 'name' => 'priority_clearance_number',  | 
            ||
| 231 | 'type' => 'number',  | 
            ||
| 232 | 'label' => 'Priority Clearance #',  | 
            ||
| 233 | ]);  | 
            ||
| 234 | $this->crud->addField([  | 
            ||
| 235 | 'name' => 'loo_issuance_date',  | 
            ||
| 236 | 'type' => 'date_picker',  | 
            ||
| 237 | 'label' => 'Letter of Offer Issuance Date',  | 
            ||
| 238 | 'date_picker_options' => [  | 
            ||
| 239 | 'todayBtn' => 'linked',  | 
            ||
| 240 | 'format' => 'yyyy-mm-dd',  | 
            ||
| 241 | ],  | 
            ||
| 242 | ]);  | 
            ||
| 243 | |||
| 244 | $this->crud->addField([  | 
            ||
| 245 | 'name' => 'internal_only',  | 
            ||
| 246 | 'type' => 'checkbox',  | 
            ||
| 247 | 'label' => 'Internal Only (Do not list this poster on the Browse Jobs page. You must access it with the direct URL.)',  | 
            ||
| 248 | ]);  | 
            ||
| 249 | |||
| 250 | $transitionManager = new JobStatusTransitionManager();  | 
            ||
| 251 | $job = $this->crud->getCurrentEntry();  | 
            ||
| 252 | $legalDestinations = $transitionManager->legalDestinations($job->job_poster_status->key);  | 
            ||
| 253 |         $validStatuses = JobPosterStatus::all()->filter(function ($status) use ($job, $legalDestinations) { | 
            ||
| 254 | return in_array($status->key, $legalDestinations) || $status->id === $job->job_poster_status_id;  | 
            ||
| 255 | });  | 
            ||
| 256 |         $statusOptions = $validStatuses->mapWithKeys(function ($status) { | 
            ||
| 257 | return [$status->id => $status->key];  | 
            ||
| 258 | });  | 
            ||
| 259 | $this->crud->addField([  | 
            ||
| 260 | 'name' => 'job_poster_status_id',  | 
            ||
| 261 | 'label' => 'Status',  | 
            ||
| 262 | 'type' => 'select_from_array',  | 
            ||
| 263 | 'options' => $statusOptions,  | 
            ||
| 264 | 'allows_null' => false,  | 
            ||
| 265 | 'default' => $job->job_poster_status_id,  | 
            ||
| 266 | ]);  | 
            ||
| 267 | |||
| 268 | // Strategic Talent Response fields  | 
            ||
| 269 | $this->crud->addField([  | 
            ||
| 270 | 'label' => 'Talent Stream',  | 
            ||
| 271 | 'type' => 'select',  | 
            ||
| 272 | 'name' => 'talent_stream_id', // the db column for the foreign key  | 
            ||
| 273 | 'entity' => 'talent_stream', // the method that defines the relationship in your Model  | 
            ||
| 274 | 'attribute' => 'name', // foreign key attribute that is shown to user  | 
            ||
| 275 | ]);  | 
            ||
| 276 | $this->crud->addField([  | 
            ||
| 277 | 'label' => 'Talent Stream Subcategory',  | 
            ||
| 278 | 'type' => 'select',  | 
            ||
| 279 | 'name' => 'talent_stream_category_id', // the db column for the foreign key  | 
            ||
| 280 | 'entity' => 'talent_stream_category', // the method that defines the relationship in your Model  | 
            ||
| 281 | 'attribute' => 'name', // foreign key attribute that is shown to user  | 
            ||
| 282 | ]);  | 
            ||
| 283 | $this->crud->addField([  | 
            ||
| 284 | 'label' => 'Job Skill Level',  | 
            ||
| 285 | 'type' => 'select',  | 
            ||
| 286 | 'name' => 'job_skill_level_id', // the db column for the foreign key  | 
            ||
| 287 | 'entity' => 'job_skill_level', // the method that defines the relationship in your Model  | 
            ||
| 288 | 'attribute' => 'name', // foreign key attribute that is shown to user  | 
            ||
| 289 | ]);  | 
            ||
| 345 |