Conditions | 12 |
Paths | 40 |
Total Lines | 53 |
Code Lines | 32 |
Lines | 14 |
Ratio | 26.42 % |
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 |
||
69 | function moduleUpdate() |
||
70 | { |
||
71 | $oDB = &DB::getInstance(); |
||
72 | $oModuleModel = getModel('module'); |
||
|
|||
73 | $oModuleController = getController('module'); |
||
74 | $version_update_id = implode('.', array(__CLASS__, __XE_VERSION__, 'updated')); |
||
75 | { |
||
76 | // 2009. 02. 11 Add site_srl to menu table |
||
77 | if(!$oDB->isColumnExists('layouts', 'site_srl')) |
||
78 | { |
||
79 | $oDB->addColumn('layouts','site_srl','number',11,0,true); |
||
80 | } |
||
81 | // 2009. 02. 26 Move the previous layout for faceoff |
||
82 | $oLayoutModel = getModel('layout'); |
||
83 | $files = FileHandler::readDir('./files/cache/layout'); |
||
84 | for($i=0,$c=count($files);$i<$c;$i++) |
||
85 | { |
||
86 | $filename = $files[$i]; |
||
87 | if(!preg_match('/([0-9]+)\.html/i',$filename,$match)) continue; |
||
88 | $layout_srl = $match[1]; |
||
89 | if(!$layout_srl) continue; |
||
90 | $path = $oLayoutModel->getUserLayoutPath($layout_srl); |
||
91 | if(!is_dir($path)) FileHandler::makeDir($path); |
||
92 | FileHandler::copyFile('./files/cache/layout/'.$filename, $path.'layout.html'); |
||
93 | @unlink('./files/cache/layout/'.$filename); |
||
94 | } |
||
95 | |||
96 | if(!$oDB->isColumnExists('layouts', 'layout_type')) |
||
97 | { |
||
98 | $oDB->addColumn('layouts','layout_type','char',1,'P',true); |
||
99 | } |
||
100 | |||
101 | $args->layout = '.'; |
||
102 | $output = executeQueryArray('layout.getLayoutDotList', $args); |
||
103 | View Code Duplication | if($output->data && count($output->data) > 0) |
|
104 | { |
||
105 | foreach($output->data as $layout) |
||
106 | { |
||
107 | $layout_path = explode('.', $layout->layout); |
||
108 | if(count($layout_path) != 2) continue; |
||
109 | if(is_dir(sprintf(_XE_PATH_ . 'themes/%s/layouts/%s', $layout_path[0], $layout_path[1]))) |
||
110 | { |
||
111 | $args->layout = implode('|@|', $layout_path); |
||
112 | $args->layout_srl = $layout->layout_srl; |
||
113 | $output = executeQuery('layout.updateLayout', $args); |
||
114 | } |
||
115 | } |
||
116 | } |
||
117 | |||
118 | $oModuleController->insertUpdatedLog($version_update_id); |
||
119 | } |
||
120 | return new Object(0, 'success_updated'); |
||
121 | } |
||
122 | |||
139 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.