Conditions | 10 |
Paths | 24 |
Total Lines | 32 |
Code Lines | 20 |
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 |
||
39 | public function makeField(string $tableName, array $field, Column $column): array |
||
40 | { |
||
41 | if (($pgSQLEnum = $this->getPgSQLEnumValue($tableName, $column->getName())) !== '') { |
||
42 | $field['type'] = ColumnType::ENUM; |
||
43 | $field['args'][] = $pgSQLEnum; |
||
44 | } else { |
||
45 | if ($field['field'] === ColumnName::REMEMBER_TOKEN && $column->getLength() === 100 && !$column->getFixed()) { |
||
46 | $field['type'] = ColumnType::REMEMBER_TOKEN; |
||
47 | $field['field'] = null; |
||
48 | $field['args'] = []; |
||
49 | } else { |
||
50 | if ($column->getFixed()) { |
||
51 | $field['type'] = ColumnType::CHAR; |
||
52 | } |
||
53 | |||
54 | if ($column->getLength() && $column->getLength() !== Builder::$defaultStringLength) { |
||
|
|||
55 | $field['args'][] = $column->getLength(); |
||
56 | } |
||
57 | } |
||
58 | } |
||
59 | |||
60 | $charset = $this->charsetModifier->generate($tableName, $column); |
||
61 | if ($charset !== '') { |
||
62 | $field['decorators'][] = $charset; |
||
63 | } |
||
64 | |||
65 | $collation = $this->collationModifier->generate($tableName, $column); |
||
66 | if ($collation !== '') { |
||
67 | $field['decorators'][] = $collation; |
||
68 | } |
||
69 | |||
70 | return $field; |
||
71 | } |
||
87 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
integer
values, zero is a special case, in particular the following results might be unexpected: