Conditions | 2 |
Paths | 2 |
Total Lines | 52 |
Code Lines | 25 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | 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 |
||
82 | public function getGetterSetterCode() { |
||
83 | |||
84 | $type = $this->column->getType(); |
||
85 | $normalizedType = TDBMDaoGenerator::dbalTypeToPhpType($type); |
||
86 | |||
87 | $columnGetterName = $this->getGetterName(); |
||
88 | $columnSetterName = $this->getSetterName(); |
||
89 | |||
90 | if ($normalizedType == "\\DateTimeInterface") { |
||
91 | $castTo = "\\DateTimeInterface "; |
||
92 | } else { |
||
93 | $castTo = ""; |
||
94 | } |
||
95 | |||
96 | $getterAndSetterCode = ' /** |
||
97 | * The getter for the "%s" column. |
||
98 | * |
||
99 | * @return %s |
||
100 | */ |
||
101 | public function %s() { |
||
102 | return $this->get(%s, %s); |
||
103 | } |
||
104 | |||
105 | /** |
||
106 | * The setter for the "%s" column. |
||
107 | * |
||
108 | * @param %s $%s |
||
109 | */ |
||
110 | public function %s(%s$%s) { |
||
111 | $this->set(%s, $%s, %s); |
||
112 | } |
||
113 | |||
114 | '; |
||
115 | return sprintf($getterAndSetterCode, |
||
116 | // Getter |
||
117 | $this->column->getName(), |
||
118 | $normalizedType, |
||
119 | $columnGetterName, |
||
120 | var_export($this->column->getName(), true), |
||
121 | var_export($this->table->getName(), true), |
||
122 | // Setter |
||
123 | $this->column->getName(), |
||
124 | $normalizedType, |
||
125 | $this->column->getName(), |
||
126 | $columnSetterName, |
||
127 | $castTo, |
||
128 | $this->column->getName(), |
||
129 | var_export($this->column->getName(), true), |
||
130 | $this->column->getName(), |
||
131 | var_export($this->table->getName(), true) |
||
132 | ); |
||
133 | } |
||
134 | |||
152 |
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
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.