| Conditions | 7 |
| Paths | 25 |
| Total Lines | 111 |
| Code Lines | 46 |
| 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 namespace XoopsModules\Tdmcreate\Files\User; |
||
| 90 | public function getUserRss($moduleDirname, $language) |
||
| 91 | { |
||
| 92 | $table = $this->getTable(); |
||
| 93 | $tableName = $table->getVar('table_name'); |
||
| 94 | $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); |
||
| 95 | foreach (array_keys($fields) as $f) { |
||
| 96 | $fieldName = $fields[$f]->getVar('field_name'); |
||
| 97 | $fieldMain[] = $fields[$f]->getVar('field_main'); |
||
| 98 | $fieldParent[] = $fields[$f]->getVar('field_parent'); |
||
| 99 | $rpFieldName = $fieldName; |
||
| 100 | if (mb_strpos($fieldName, '_')) { |
||
| 101 | $str = mb_strpos($fieldName, '_'); |
||
| 102 | if (false !== $str) { |
||
| 103 | $rpFieldName = mb_substr($fieldName, $str + 1, mb_strlen($fieldName)); |
||
| 104 | } |
||
| 105 | } |
||
| 106 | $lpFieldName = mb_substr($fieldName, 0, mb_strpos($fieldName, '_')); |
||
| 107 | if (0 == $f) { |
||
| 108 | $fieldId = $fieldName; |
||
| 109 | } |
||
| 110 | if (in_array(1, $fieldMain)) { |
||
| 111 | $fpmf = $fieldName; |
||
| 112 | } |
||
| 113 | if (in_array(1, $fieldParent)) { |
||
| 114 | $fppf = $fieldName; |
||
| 115 | } else { |
||
| 116 | $fppf = 'cid'; |
||
| 117 | } |
||
| 118 | } |
||
| 119 | $ret = $this->getInclude(); |
||
| 120 | |||
| 121 | $ret = <<<EOT |
||
| 122 | |||
| 123 | \${$fppf} = {$moduleDirname}_CleanVars(\$_GET, '{$fppf}', 0); |
||
| 124 | include_once XOOPS_ROOT_PATH.'/class/template.php'; |
||
| 125 | if (function_exists('mb_http_output')) { |
||
| 126 | mb_http_output('pass'); |
||
| 127 | } |
||
| 128 | //header ('Content-Type:text/xml; charset=UTF-8'); |
||
| 129 | \${$moduleDirname}->geConfig('utf8') = false; |
||
| 130 | |||
| 131 | \$tpl = new \XoopsTpl(); |
||
| 132 | \$tpl->xoops_setCaching(2); //1 = Cache global, 2 = Cache individual (for template) |
||
| 133 | \$tpl->xoops_setCacheTime(\${$moduleDirname}->geConfig('timecacherss')*60); // Time of the cache on seconds |
||
| 134 | \$categories = {$moduleDirname}MyGetItemIds('{$moduleDirname}_view', '{$moduleDirname}'); |
||
| 135 | \$criteria = new \CriteriaCompo(); |
||
| 136 | |||
| 137 | \$criteria->add(new \Criteria('cat_status', 0, '!=')); |
||
| 138 | \$criteria->add(new \Criteria('{$fppf}', '(' . implode(',', \$categories) . ')','IN')); |
||
| 139 | if (\${$fppf} != 0){ |
||
| 140 | \$criteria->add(new \Criteria('{$fppf}', \${$fppf})); |
||
| 141 | \${$tableName} = \${$tableName}Handler->get(\${$fppf}); |
||
| 142 | \$title = \$xoopsConfig['sitename'] . ' - ' . \$xoopsModule->getVar('name') . ' - ' . \${$tableName}->getVar('{$fpmf}'); |
||
| 143 | } else { |
||
| 144 | \$title = \$xoopsConfig['sitename'] . ' - ' . \$xoopsModule->getVar('name'); |
||
| 145 | } |
||
| 146 | \$criteria->setLimit(\${$moduleDirname}->geConfig('perpagerss')); |
||
| 147 | \$criteria->setSort('date'); |
||
| 148 | \$criteria->setOrder('DESC'); |
||
| 149 | \${$tableName}Arr = \${$tableName}Handler->getAll(\$criteria); |
||
| 150 | unset(\$criteria); |
||
| 151 | |||
| 152 | if (!\$tpl->is_cached('db:{$moduleDirname}_rss.tpl', \${$fppf})) { |
||
| 153 | \$tpl->assign('channel_title', htmlspecialchars(\$title, ENT_QUOTES)); |
||
| 154 | \$tpl->assign('channel_link', XOOPS_URL.'/'); |
||
| 155 | \$tpl->assign('channel_desc', htmlspecialchars(\$xoopsConfig['slogan'], ENT_QUOTES)); |
||
| 156 | \$tpl->assign('channel_lastbuild', formatTimestamp(time(), 'rss')); |
||
| 157 | \$tpl->assign('channel_webmaster', \$xoopsConfig['adminmail']); |
||
| 158 | \$tpl->assign('channel_editor', \$xoopsConfig['adminmail']); |
||
| 159 | \$tpl->assign('channel_category', 'Event'); |
||
| 160 | \$tpl->assign('channel_generator', 'XOOPS - ' . htmlspecialchars(\$xoopsModule->getVar('{$fpmf}'), ENT_QUOTES)); |
||
| 161 | \$tpl->assign('channel_language', _LANGCODE); |
||
| 162 | if ( _LANGCODE == 'fr' ) { |
||
| 163 | \$tpl->assign('docs', 'http://www.scriptol.fr/rss/RSS-2.0.html'); |
||
| 164 | } else { |
||
| 165 | \$tpl->assign('docs', 'http://cyber.law.harvard.edu/rss/rss.html'); |
||
| 166 | } |
||
| 167 | \$tpl->assign('image_url', XOOPS_URL . \$xoopsModuleConfig['logorss']); |
||
| 168 | \$dimention = getimagesize(XOOPS_ROOT_PATH . \$xoopsModuleConfig['logorss']); |
||
| 169 | if (empty(\$dimention[0])) { |
||
| 170 | \$width = 88; |
||
| 171 | } else { |
||
| 172 | \$width = (\$dimention[0] > 144) ? 144 : \$dimention[0]; |
||
| 173 | } |
||
| 174 | if (empty(\$dimention[1])) { |
||
| 175 | \$height = 31; |
||
| 176 | } else { |
||
| 177 | \$height = (\$dimention[1] > 400) ? 400 : \$dimention[1]; |
||
| 178 | } |
||
| 179 | \$tpl->assign('image_width', \$width); |
||
| 180 | \$tpl->assign('image_height', \$height); |
||
| 181 | foreach (array_keys(\${$tableName}Arr) as \$i) { |
||
| 182 | \$description = \${$tableName}Arr[\$i]->getVar('description'); |
||
| 183 | //permet d'afficher uniquement la description courte |
||
| 184 | if (strpos(\$description,'[pagebreak]')==false){ |
||
| 185 | \$description_short = \$description; |
||
| 186 | } else { |
||
| 187 | \$description_short = substr(\$description,0,strpos(\$description,'[pagebreak]')); |
||
| 188 | } |
||
| 189 | \$tpl->append('items', array('title' => htmlspecialchars(\${$tableName}Arr[\$i]->getVar('{$fpmf}'), ENT_QUOTES), |
||
| 190 | 'link' => XOOPS_URL . '/modules/{$moduleDirname}/single.php?{$fppf}=' . \${$tableName}Arr[\$i]->getVar('{$fppf}') . '&{$fieldId}=' . \${$tableName}Arr[\$i]->getVar('{$fieldId}'), |
||
| 191 | 'guid' => XOOPS_URL . '/modules/{$moduleDirname}/single.php?{$fppf}=' . \${$tableName}Arr[\$i]->getVar('{$fppf}') . '&{$fieldId}=' . \${$tableName}Arr[\$i]->getVar('{$fieldId}'), |
||
| 192 | 'pubdate' => formatTimestamp(\${$tableName}Arr[\$i]->getVar('date'), 'rss'), |
||
| 193 | 'description' => htmlspecialchars(\$description_short, ENT_QUOTES))); |
||
| 194 | } |
||
| 195 | } |
||
| 196 | header('Content-Type:text/xml; charset=' . _CHARSET); |
||
| 197 | \$tpl->display('db:{$moduleDirname}_rss.tpl', \${$fppf}); |
||
| 198 | EOT; |
||
| 199 | |||
| 200 | return $ret; |
||
| 201 | } |
||
| 221 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..