Conditions | 13 |
Paths | 13 |
Total Lines | 31 |
Code Lines | 28 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
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 |
||
9 | public function create($name, $type, array $options = array()) |
||
10 | { |
||
11 | switch ($type) { |
||
12 | case 'string': |
||
13 | return new StringColumn($name, $options); |
||
14 | case 'text': |
||
15 | return new TextColumn($name, $options); |
||
16 | case 'integer': |
||
17 | return new IntegerColumn($name, $options); |
||
18 | case 'biginteger': |
||
19 | return new BigIntegerColumn($name, $options); |
||
20 | case 'smallinteger': |
||
21 | return new SmallIntegerColumn($name, $options); |
||
22 | case 'float': |
||
23 | return new FloatColumn($name, $options); |
||
24 | case 'decimal': |
||
25 | return new DecimalColumn($name, $options); |
||
26 | case 'boolean': |
||
27 | return new BooleanColumn($name, $options); |
||
28 | case 'date': |
||
29 | return new DateColumn($name, $options); |
||
30 | case 'time': |
||
31 | return new TimeColumn($name, $options); |
||
32 | case 'datetime': |
||
33 | return new DateTimeColumn($name, $options); |
||
34 | case 'binary': |
||
35 | return new BinaryColumn($name, $options); |
||
36 | default: |
||
37 | throw new NotSupportedException(sprintf('Type %s is not suppoted.', $type)); |
||
38 | } |
||
39 | } |
||
40 | } |
||
41 |