| Conditions | 2 |
| Paths | 1 |
| Total Lines | 94 |
| Code Lines | 72 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
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 |
||
| 171 | public function setupUpdateOperation() |
||
| 172 | { |
||
| 173 | $this->crud->addField([ |
||
| 174 | 'name' => 'title', |
||
| 175 | 'label' => 'Title', |
||
| 176 | 'type' => 'text', |
||
| 177 | 'attributes' => [ |
||
| 178 | 'readonly' => 'readonly' |
||
| 179 | ] |
||
| 180 | ]); |
||
| 181 | $this->crud->addField([ |
||
| 182 | 'name' => 'salary_min', |
||
| 183 | 'type' => 'number', |
||
| 184 | 'label' => 'Minimum Salary', |
||
| 185 | ]); |
||
| 186 | $this->crud->addField([ |
||
| 187 | 'name' => 'salary_max', |
||
| 188 | 'type' => 'number', |
||
| 189 | 'label' => 'Maximum Salary', |
||
| 190 | ]); |
||
| 191 | $this->crud->addField([ |
||
| 192 | 'name' => 'noc', |
||
| 193 | 'type' => 'number', |
||
| 194 | 'label' => 'NOC Code', |
||
| 195 | ]); |
||
| 196 | $this->crud->addField([ |
||
| 197 | 'name' => 'open_date_time', |
||
| 198 | 'label' => 'Open Date', |
||
| 199 | 'type' => 'date_picker', |
||
| 200 | 'date_picker_options' => [ |
||
| 201 | 'todayBtn' => 'linked', |
||
| 202 | 'format' => 'yyyy-mm-dd', |
||
| 203 | ], |
||
| 204 | ]); |
||
| 205 | $this->crud->addField([ |
||
| 206 | 'name' => 'close_date_time', |
||
| 207 | 'label' => 'Close Date', |
||
| 208 | 'type' => 'date_picker', |
||
| 209 | 'date_picker_options' => [ |
||
| 210 | 'todayBtn' => 'linked', |
||
| 211 | 'format' => 'yyyy-mm-dd', |
||
| 212 | ], |
||
| 213 | ]); |
||
| 214 | $this->crud->addField([ |
||
| 215 | 'name' => 'start_date_time', |
||
| 216 | 'label' => 'Start Date', |
||
| 217 | 'type' => 'date_picker', |
||
| 218 | 'date_picker_options' => [ |
||
| 219 | 'todayBtn' => 'linked', |
||
| 220 | 'format' => 'yyyy-mm-dd', |
||
| 221 | ], |
||
| 222 | ]); |
||
| 223 | $this->crud->addField([ |
||
| 224 | 'name' => 'process_number', |
||
| 225 | 'type' => 'text', |
||
| 226 | 'label' => 'Process #', |
||
| 227 | ]); |
||
| 228 | $this->crud->addField([ |
||
| 229 | 'name' => 'priority_clearance_number', |
||
| 230 | 'type' => 'number', |
||
| 231 | 'label' => 'Priority Clearance #', |
||
| 232 | ]); |
||
| 233 | $this->crud->addField([ |
||
| 234 | 'name' => 'loo_issuance_date', |
||
| 235 | 'type' => 'date_picker', |
||
| 236 | 'label' => 'Letter of Offer Issuance Date', |
||
| 237 | 'date_picker_options' => [ |
||
| 238 | 'todayBtn' => 'linked', |
||
| 239 | 'format' => 'yyyy-mm-dd', |
||
| 240 | ], |
||
| 241 | ]); |
||
| 242 | |||
| 243 | $this->crud->addField([ |
||
| 244 | 'name' => 'internal_only', |
||
| 245 | 'type' => 'checkbox', |
||
| 246 | 'label' => 'Internal Only (Do not list this poster on the Browse Jobs page. You must access it with the direct URL.)', |
||
| 247 | ]); |
||
| 248 | |||
| 249 | $transitionManager = new JobStatusTransitionManager(); |
||
| 250 | $job = $this->crud->getCurrentEntry(); |
||
| 251 | $legalDestinations = $transitionManager->legalDestinations($job->job_poster_status->key); |
||
| 252 | $validStatuses = JobPosterStatus::all()->filter(function ($status) use ($job, $legalDestinations) { |
||
| 253 | return in_array($status->key, $legalDestinations) || $status->id === $job->job_poster_status_id; |
||
| 254 | }); |
||
| 255 | $statusOptions = $validStatuses->mapWithKeys(function ($status) { |
||
| 256 | return [$status->id => $status->key]; |
||
| 257 | }); |
||
| 258 | $this->crud->addField([ |
||
| 259 | 'name' => 'job_poster_status_id', |
||
| 260 | 'label' => 'Status', |
||
| 261 | 'type' => 'select_from_array', |
||
| 262 | 'options' => $statusOptions, |
||
| 263 | 'allows_null' => false, |
||
| 264 | 'default' => $job->job_poster_status_id, |
||
| 265 | ]); |
||
| 289 |