Conditions | 10 |
Paths | 10 |
Total Lines | 32 |
Code Lines | 20 |
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 |
||
31 | public function process(IAdapter $adapter, $lookup, $column, $value) |
||
32 | { |
||
33 | switch ($lookup) { |
||
34 | case 'regex': |
||
35 | return 'BINARY ' . $adapter->quoteColumn($column) . ' REGEXP ' . $adapter->quoteValue($value); |
||
36 | |||
37 | case 'iregex': |
||
38 | return $adapter->quoteColumn($column) . ' REGEXP ' . $adapter->quoteValue($value); |
||
39 | |||
40 | case 'second': |
||
41 | return 'EXTRACT(SECOND FROM ' . $adapter->quoteColumn($column) . ')=' . $adapter->quoteValue((string)$value); |
||
42 | |||
43 | case 'year': |
||
44 | return 'EXTRACT(YEAR FROM ' . $adapter->quoteColumn($column) . ')=' . $adapter->quoteValue((string)$value); |
||
45 | |||
46 | case 'minute': |
||
47 | return 'EXTRACT(MINUTE FROM ' . $adapter->quoteColumn($column) . ')=' . $adapter->quoteValue((string)$value); |
||
48 | |||
49 | case 'hour': |
||
50 | return 'EXTRACT(HOUR FROM ' . $adapter->quoteColumn($column) . ')=' . $adapter->quoteValue((string)$value); |
||
51 | |||
52 | case 'day': |
||
53 | return 'EXTRACT(DAY FROM ' . $adapter->quoteColumn($column) . ')=' . $adapter->quoteValue((string)$value); |
||
54 | |||
55 | case 'month': |
||
56 | return 'EXTRACT(MONTH FROM ' . $adapter->quoteColumn($column) . ')=' . $adapter->quoteValue((string)$value); |
||
57 | |||
58 | case 'week_day': |
||
59 | return 'DAYOFWEEK(' . $adapter->quoteColumn($column) . ')=' . $adapter->quoteValue((string)$value); |
||
60 | } |
||
61 | |||
62 | return parent::process($adapter, $lookup, $column, $value); |
||
63 | } |
||
64 | } |