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 |
||
72 | public function prepareVars() |
||
73 | { |
||
74 | foreach ($this->vars as $k => $v) { |
||
75 | $cleanv = $this->cleanVars[$k]; |
||
76 | switch ($v['data_type']) { |
||
77 | case \XOBJ_DTYPE_TXTBOX: |
||
78 | case \XOBJ_DTYPE_TXTAREA: |
||
79 | case \XOBJ_DTYPE_SOURCE: |
||
80 | case \XOBJ_DTYPE_EMAIL: |
||
81 | $cleanv = $v['changed'] ? $cleanv : ''; |
||
82 | if (!isset($v['not_gpc']) || !$v['not_gpc']) { |
||
83 | $cleanv = $this->db->quoteString($cleanv); |
||
84 | } |
||
85 | break; |
||
86 | case \XOBJ_DTYPE_INT: |
||
87 | $cleanv = $v['changed'] ? (int)$cleanv : 0; |
||
88 | break; |
||
89 | case \XOBJ_DTYPE_ARRAY: |
||
90 | $cleanv = $v['changed'] ? $cleanv : \serialize([]); |
||
91 | break; |
||
92 | case \XOBJ_DTYPE_STIME: |
||
93 | case \XOBJ_DTYPE_MTIME: |
||
94 | case \XOBJ_DTYPE_LTIME: |
||
95 | $cleanv = $v['changed'] ? $cleanv : 0; |
||
96 | break; |
||
97 | default: |
||
98 | break; |
||
99 | } |
||
100 | $this->cleanVars[$k] = &$cleanv; |
||
101 | unset($cleanv); |
||
102 | } |
||
103 | |||
104 | return true; |
||
105 | } |
||
120 |