| Conditions | 1 |
| Paths | 1 |
| Total Lines | 99 |
| Code Lines | 60 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 1 | Features | 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 |
||
| 24 | public function init() |
||
| 25 | { |
||
| 26 | $this->setName('education') |
||
| 27 | ->setHydrator(new EntityHydrator()) |
||
| 28 | ->setObject(new EducationEntity()); |
||
| 29 | |||
| 30 | $this->add( |
||
| 31 | array( |
||
| 32 | 'type' => 'Core/Datepicker', |
||
| 33 | 'name' => 'startDate', |
||
| 34 | 'options' => array( |
||
| 35 | 'label' => /*@translate*/ 'Start date', |
||
| 36 | 'data-width' => '50%', |
||
| 37 | 'class' => 'selectpicker' |
||
| 38 | ) |
||
| 39 | ) |
||
| 40 | ); |
||
| 41 | $this->add( |
||
| 42 | array( |
||
| 43 | 'type' => 'Core/Datepicker', |
||
| 44 | 'name' => 'endDate', |
||
| 45 | 'options' => array( |
||
| 46 | 'label' => /*@translate*/ 'End date' |
||
| 47 | ) |
||
| 48 | ) |
||
| 49 | ); |
||
| 50 | $this->add( |
||
| 51 | array( |
||
| 52 | 'type' => 'checkbox', |
||
| 53 | 'name' => 'currentIndicator', |
||
| 54 | 'options' => array( |
||
| 55 | 'label' => /*@translate */ 'ongoing' |
||
| 56 | ) |
||
| 57 | ) |
||
| 58 | ); |
||
| 59 | |||
| 60 | $this->add( |
||
| 61 | array( |
||
| 62 | 'name' => 'competencyName', |
||
| 63 | 'options' => array( |
||
| 64 | 'label' => /*@translate */ 'Degree'), |
||
| 65 | 'attributes' => array( |
||
| 66 | //'id' => 'education-competencyname', |
||
|
|
|||
| 67 | 'title' => /*@translate */ 'please enter the name of your qualification' |
||
| 68 | ), |
||
| 69 | ) |
||
| 70 | ); |
||
| 71 | |||
| 72 | $this->add( |
||
| 73 | array( |
||
| 74 | 'name' => 'organizationName', |
||
| 75 | 'options' => array( |
||
| 76 | 'label' => /*@translate */ 'Organization Name'), |
||
| 77 | 'attributes' => array( |
||
| 78 | //'id' => 'education-organizationname', |
||
| 79 | 'title' => /*@translate */ 'please enter the name of the university or school' |
||
| 80 | ), |
||
| 81 | ) |
||
| 82 | ); |
||
| 83 | |||
| 84 | $this->add( |
||
| 85 | array( |
||
| 86 | 'name' => 'country', |
||
| 87 | 'options' => array( |
||
| 88 | 'label' => /*@translate */ 'Country'), |
||
| 89 | 'attributes' => array( |
||
| 90 | //'id' => 'education-country', |
||
| 91 | 'title' => /*@translate */ 'please select the country' |
||
| 92 | ), |
||
| 93 | ) |
||
| 94 | ); |
||
| 95 | |||
| 96 | $this->add( |
||
| 97 | array( |
||
| 98 | 'name' => 'city', |
||
| 99 | 'options' => array( |
||
| 100 | 'label' => /*@translate */ 'City'), |
||
| 101 | 'attributes' => array( |
||
| 102 | //'id' => 'education-city', |
||
| 103 | 'title' => /*@translate */ 'please enter the name of the city' |
||
| 104 | ), |
||
| 105 | ) |
||
| 106 | ); |
||
| 107 | |||
| 108 | $this->add( |
||
| 109 | array( |
||
| 110 | 'name' => 'description', |
||
| 111 | 'type' => 'Zend\Form\Element\Textarea', |
||
| 112 | 'options' => array( |
||
| 113 | 'label' => /*@translate */ 'Description', |
||
| 114 | ), |
||
| 115 | 'attributes' => array( |
||
| 116 | //'id' => 'education-description', |
||
| 117 | 'title' => /*@translate */ 'please enter a description', |
||
| 118 | ), |
||
| 119 | ) |
||
| 120 | ); |
||
| 121 | |||
| 122 | } |
||
| 123 | |||
| 153 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.