| Conditions | 5 |
| Paths | 2 |
| Total Lines | 56 |
| Code Lines | 25 |
| 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 |
||
| 122 | public function getGetterSetterCode() |
||
| 123 | { |
||
| 124 | $type = $this->column->getType(); |
||
| 125 | $normalizedType = TDBMDaoGenerator::dbalTypeToPhpType($type); |
||
| 126 | |||
| 127 | $columnGetterName = $this->getGetterName(); |
||
| 128 | $columnSetterName = $this->getSetterName(); |
||
| 129 | |||
| 130 | // A column type can be forced if it is not nullable and not auto-incrementable (for auto-increment columns, we can get "null" as long as the bean is not saved). |
||
| 131 | $isNullable = !$this->column->getNotnull() || $this->column->getAutoincrement(); |
||
| 132 | |||
| 133 | $getterAndSetterCode = ' /** |
||
| 134 | * The getter for the "%s" column. |
||
| 135 | * |
||
| 136 | * @return %s |
||
| 137 | */ |
||
| 138 | public function %s() : %s%s |
||
| 139 | { |
||
| 140 | return $this->get(%s, %s); |
||
| 141 | } |
||
| 142 | |||
| 143 | /** |
||
| 144 | * The setter for the "%s" column. |
||
| 145 | * |
||
| 146 | * @param %s $%s |
||
| 147 | */ |
||
| 148 | public function %s(%s%s $%s) : void |
||
| 149 | { |
||
| 150 | $this->set(%s, $%s, %s); |
||
| 151 | } |
||
| 152 | |||
| 153 | '; |
||
| 154 | |||
| 155 | return sprintf($getterAndSetterCode, |
||
| 156 | // Getter |
||
| 157 | $this->column->getName(), |
||
| 158 | $normalizedType.($isNullable ? '|null' : ''), |
||
| 159 | $columnGetterName, |
||
| 160 | ($isNullable ? '?' : ''), |
||
| 161 | $normalizedType, |
||
| 162 | var_export($this->column->getName(), true), |
||
| 163 | var_export($this->table->getName(), true), |
||
| 164 | // Setter |
||
| 165 | $this->column->getName(), |
||
| 166 | $normalizedType, |
||
| 167 | $this->column->getName(), |
||
| 168 | $columnSetterName, |
||
| 169 | $this->column->getNotnull() ? '' : '?', |
||
| 170 | $normalizedType, |
||
| 171 | //$castTo, |
||
| 172 | $this->column->getName(), |
||
| 173 | var_export($this->column->getName(), true), |
||
| 174 | $this->column->getName(), |
||
| 175 | var_export($this->table->getName(), true) |
||
| 176 | ); |
||
| 177 | } |
||
| 178 | |||
| 206 |