| Conditions | 1 |
| Paths | 1 |
| Total Lines | 78 |
| Code Lines | 53 |
| 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 |
||
| 57 | public function init() |
||
| 58 | { |
||
| 59 | $elements = [ |
||
| 60 | 'general' => [ |
||
| 61 | 'priority' => 100, |
||
| 62 | 'options' => [ 'label' => 'Basic Data' ], |
||
| 63 | 'property' => true, |
||
| 64 | 'forms' => [ |
||
| 65 | |||
| 66 | 'locationForm' => array( |
||
| 67 | 'type' => 'Jobs/Base', |
||
| 68 | 'property' => true, |
||
| 69 | 'options' => array( |
||
| 70 | 'enable_descriptions' => true, |
||
| 71 | 'description' => /*@translate*/ 'Please choose a descriptive title and a location for your job posting ', |
||
| 72 | 'display_mode' => 'summary' |
||
| 73 | ) |
||
| 74 | ), |
||
| 75 | 'nameForm' => array( |
||
| 76 | 'type' => 'Jobs/CompanyName', |
||
| 77 | 'property' => true, |
||
| 78 | 'options' => array( |
||
| 79 | 'enable_descriptions' => true, |
||
| 80 | 'description' => /*@translate*/ 'Please choose the name of the hiring organization. The selected name defines the template of the job opening.', |
||
| 81 | 'display_mode' => 'summary' |
||
| 82 | ) |
||
| 83 | ), |
||
| 84 | 'classifications' => [ |
||
| 85 | 'type' => 'Jobs/Classifications', |
||
| 86 | 'options' => [ |
||
| 87 | 'enable_descriptions' => true, |
||
| 88 | 'description' => /*@translate*/ 'Classify the job.', |
||
| 89 | 'display_mode' => 'summary', |
||
| 90 | ], |
||
| 91 | ], |
||
| 92 | 'portalForm' => array( |
||
| 93 | 'type' => 'Jobs/Multipost', |
||
| 94 | 'property' => true, |
||
| 95 | 'options' => array( |
||
| 96 | 'enable_descriptions' => true, |
||
| 97 | 'description' => /*@translate*/ 'Please choose the portals, where you wish to publish your job opening.', |
||
| 98 | 'display_mode' => 'summary' |
||
| 99 | ) |
||
| 100 | ), |
||
| 101 | ], |
||
| 102 | ], |
||
| 103 | |||
| 104 | 'description' => [ |
||
| 105 | 'priority' => '80', |
||
| 106 | 'options' => [ 'label' => 'Job opening' ], |
||
| 107 | 'property' => true, |
||
| 108 | 'forms' => [ |
||
| 109 | 'descriptionForm' => array( |
||
| 110 | 'type' => 'Jobs/Description', |
||
| 111 | 'property' => true, |
||
| 112 | ), |
||
| 113 | ], |
||
| 114 | ], |
||
| 115 | |||
| 116 | 'preview' => [ |
||
| 117 | 'priority' => 60, |
||
| 118 | 'options' => [ 'label' => 'Preview' ], |
||
| 119 | 'property' => true, |
||
| 120 | 'forms' => [ |
||
| 121 | 'previewForm' => array( |
||
| 122 | 'type' => 'Jobs/Preview', |
||
| 123 | 'property' => true, |
||
| 124 | ), |
||
| 125 | ], |
||
| 126 | ], |
||
| 127 | |||
| 128 | ]; |
||
| 129 | |||
| 130 | $this->setForms($elements); |
||
| 131 | |||
| 132 | $events = $this->getEventManager(); |
||
| 133 | $events->trigger(FormEvent::EVENT_INIT, $this); |
||
| 134 | } |
||
| 135 | |||
| 204 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.