Conditions | 16 |
Paths | 15 |
Total Lines | 42 |
Code Lines | 30 |
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 |
||
26 | protected function generateColumns(EmberClassGenerator $class, Table $model) { |
||
27 | $codegen = $this->getCodegen(); |
||
28 | $filter = $this->getColumnFilter($codegen, $model); |
||
29 | foreach ($model->getColumns() as $col) { |
||
30 | if (in_array($col, $filter)) { |
||
31 | continue; |
||
32 | } |
||
33 | |||
34 | if ($col->isForeignKey() || $col->isPrimaryKey()) { |
||
35 | continue; |
||
36 | } |
||
37 | |||
38 | $prop = NameUtils::toCamelCase($col->getPhpName()); |
||
39 | |||
40 | switch ($col->getType()) { |
||
41 | case 'NUMERIC': |
||
42 | case 'DECIMAL': |
||
43 | case 'TINYINT': |
||
44 | case 'SMALLINT': |
||
45 | case 'INTEGER': |
||
46 | case 'BIGINT': |
||
47 | case 'REAL': |
||
48 | case 'FLOAT': |
||
49 | case 'DOUBLE': |
||
50 | $value = 'attr(\'number\')'; |
||
51 | break; |
||
52 | |||
53 | case 'BOOLEAN': |
||
54 | $value = 'attr(\'boolean\')'; |
||
55 | break; |
||
56 | |||
57 | case 'TIMESTAMP': |
||
58 | $value = 'attr(\'date\')'; |
||
59 | break; |
||
60 | |||
61 | default: |
||
62 | $value = 'attr(\'string\')'; |
||
63 | } |
||
64 | |||
65 | $class->setProperty($prop, $value); |
||
66 | } |
||
67 | } |
||
68 | |||
125 | } |