| Conditions | 2 |
| Paths | 2 |
| Total Lines | 53 |
| Code Lines | 25 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| 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 |
||
| 91 | public function getGetterSetterCode() |
||
| 92 | { |
||
| 93 | $type = $this->column->getType(); |
||
| 94 | $normalizedType = TDBMDaoGenerator::dbalTypeToPhpType($type); |
||
| 95 | |||
| 96 | $columnGetterName = $this->getGetterName(); |
||
| 97 | $columnSetterName = $this->getSetterName(); |
||
| 98 | |||
| 99 | if ($normalizedType == '\\DateTimeInterface') { |
||
| 100 | $castTo = '\\DateTimeInterface '; |
||
| 101 | } else { |
||
| 102 | $castTo = ''; |
||
| 103 | } |
||
| 104 | |||
| 105 | $getterAndSetterCode = ' /** |
||
| 106 | * The getter for the "%s" column. |
||
| 107 | * |
||
| 108 | * @return %s |
||
| 109 | */ |
||
| 110 | public function %s() { |
||
| 111 | return $this->get(%s, %s); |
||
| 112 | } |
||
| 113 | |||
| 114 | /** |
||
| 115 | * The setter for the "%s" column. |
||
| 116 | * |
||
| 117 | * @param %s $%s |
||
| 118 | */ |
||
| 119 | public function %s(%s$%s) { |
||
| 120 | $this->set(%s, $%s, %s); |
||
| 121 | } |
||
| 122 | |||
| 123 | '; |
||
| 124 | |||
| 125 | return sprintf($getterAndSetterCode, |
||
| 126 | // Getter |
||
| 127 | $this->column->getName(), |
||
| 128 | $normalizedType, |
||
| 129 | $columnGetterName, |
||
| 130 | var_export($this->column->getName(), true), |
||
| 131 | var_export($this->table->getName(), true), |
||
| 132 | // Setter |
||
| 133 | $this->column->getName(), |
||
| 134 | $normalizedType, |
||
| 135 | $this->column->getName(), |
||
| 136 | $columnSetterName, |
||
| 137 | $castTo, |
||
| 138 | $this->column->getName(), |
||
| 139 | var_export($this->column->getName(), true), |
||
| 140 | $this->column->getName(), |
||
| 141 | var_export($this->table->getName(), true) |
||
| 142 | ); |
||
| 143 | } |
||
| 144 | |||
| 171 |