| Conditions | 10 |
| Paths | 12 |
| Total Lines | 29 |
| Code Lines | 19 |
| 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 |
||
| 24 | public function __construct($type = 'config', $params) |
||
| 25 | { |
||
| 26 | if (isset($params)) { |
||
| 27 | switch ($type) { |
||
| 28 | case 'db': |
||
| 29 | //TODO: Implement this way of object creation. |
||
| 30 | break; |
||
| 31 | case 'config': // Do the same as the default. |
||
| 32 | default: |
||
| 33 | foreach ($params as $a => $value) { |
||
| 34 | switch ($a) { |
||
| 35 | case 'system_id': |
||
| 36 | $this->identifier = strtolower($value); |
||
| 37 | break; |
||
| 38 | case 'member': |
||
| 39 | if (strstr($value, ',') !== false) { |
||
| 40 | $temp = explode(',', $value); |
||
| 41 | foreach ($temp as $val) { |
||
| 42 | if (!empty($val)) { |
||
| 43 | $this->members[] = $val; |
||
| 44 | } |
||
| 45 | } |
||
| 46 | } |
||
| 47 | break; |
||
| 48 | } |
||
| 49 | } |
||
| 50 | } |
||
| 51 | } |
||
| 52 | } |
||
| 53 | } |
||
| 54 |