| Conditions | 14 |
| Paths | 14 |
| Total Lines | 38 |
| Code Lines | 28 |
| 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 |
||
| 35 | protected function generateColumns(EmberClassGenerator $class, Table $model) { |
||
| 36 | $codegen = $this->getCodegen(); |
||
| 37 | $filter = $this->getColumnFilter($codegen, $model); |
||
| 38 | foreach ($model->getColumns() as $col) { |
||
| 39 | if (in_array($col, $filter)) { |
||
| 40 | continue; |
||
| 41 | } |
||
| 42 | |||
| 43 | $prop = NameUtils::toCamelCase($col->getPhpName()); |
||
| 44 | |||
| 45 | switch ($col->getType()) { |
||
| 46 | case 'NUMERIC': |
||
| 47 | case 'DECIMAL': |
||
| 48 | case 'TINYINT': |
||
| 49 | case 'SMALLINT': |
||
| 50 | case 'INTEGER': |
||
| 51 | case 'BIGINT': |
||
| 52 | case 'REAL': |
||
| 53 | case 'FLOAT': |
||
| 54 | case 'DOUBLE': |
||
| 55 | $value = 'attr(\'number\')'; |
||
| 56 | break; |
||
| 57 | |||
| 58 | case 'BOOLEAN': |
||
| 59 | $value = 'attr(\'boolean\')'; |
||
| 60 | break; |
||
| 61 | |||
| 62 | case 'DATE': |
||
| 63 | $value = 'attr(\'date\')'; |
||
| 64 | break; |
||
| 65 | |||
| 66 | default: |
||
| 67 | $value = 'attr(\'string\')'; |
||
| 68 | } |
||
| 69 | |||
| 70 | $class->setProperty($prop, $value); |
||
| 71 | } |
||
| 72 | } |
||
| 73 | |||
| 143 | } |
Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a
@returnannotation as described here.