| Conditions | 17 |
| Paths | 28 |
| Total Lines | 33 |
| Code Lines | 27 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| 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 |
||
| 58 | public function prepareVars() |
||
| 59 | { |
||
| 60 | foreach ($this->vars as $k => $v) { |
||
| 61 | $cleanv = $this->cleanVars[$k]; |
||
| 62 | switch ($v['data_type']) { |
||
| 63 | case XOBJ_DTYPE_TXTBOX: |
||
| 64 | case XOBJ_DTYPE_TXTAREA: |
||
| 65 | case XOBJ_DTYPE_SOURCE: |
||
| 66 | case XOBJ_DTYPE_EMAIL: |
||
| 67 | $cleanv = $v['changed'] ? $cleanv : ''; |
||
| 68 | if (!isset($v['not_gpc']) || !$v['not_gpc']) { |
||
| 69 | $cleanv = $this->db->quoteString($cleanv); |
||
| 70 | } |
||
| 71 | break; |
||
| 72 | case XOBJ_DTYPE_INT: |
||
| 73 | $cleanv = $v['changed'] ? (int)$cleanv : 0; |
||
| 74 | break; |
||
| 75 | case XOBJ_DTYPE_ARRAY: |
||
| 76 | $cleanv = $v['changed'] ? $cleanv : serialize([]); |
||
| 77 | break; |
||
| 78 | case XOBJ_DTYPE_STIME: |
||
| 79 | case XOBJ_DTYPE_MTIME: |
||
| 80 | case XOBJ_DTYPE_LTIME: |
||
| 81 | $cleanv = $v['changed'] ? $cleanv : 0; |
||
| 82 | break; |
||
| 83 | default: |
||
| 84 | break; |
||
| 85 | } |
||
| 86 | $this->cleanVars[$k] = &$cleanv; |
||
| 87 | unset($cleanv); |
||
| 88 | } |
||
| 89 | |||
| 90 | return true; |
||
| 91 | } |
||
| 106 |