| Conditions | 11 |
| Paths | 160 |
| Total Lines | 72 |
| Code Lines | 60 |
| 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; |
||
| 89 | public function getUserPrint($moduleDirname, $language) |
||
| 90 | { |
||
| 91 | $stuModuleDirname = mb_strtoupper($moduleDirname); |
||
| 92 | $table = $this->getTable(); |
||
| 93 | $tableName = $table->getVar('table_name'); |
||
| 94 | $tableSoleName = $table->getVar('table_solename'); |
||
| 95 | $ucfModuleDirname = ucfirst($moduleDirname); |
||
| 96 | $ucfTableName = ucfirst($tableName); |
||
| 97 | $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); |
||
| 98 | foreach (array_keys($fields) as $f) { |
||
| 99 | $fieldName = $fields[$f]->getVar('field_name'); |
||
| 100 | $rpFieldName = $fieldName; |
||
| 101 | if (mb_strpos($fieldName, '_')) { |
||
| 102 | $str = mb_strpos($fieldName, '_'); |
||
| 103 | if (false !== $str) { |
||
| 104 | $rpFieldName = mb_substr($fieldName, $str + 1, mb_strlen($fieldName)); |
||
| 105 | } |
||
| 106 | } |
||
| 107 | if ((0 == $f) && (1 == $this->table->getVar('table_autoincrement'))) { |
||
| 108 | $fieldId = $fieldName; |
||
| 109 | } else { |
||
| 110 | if (1 == $fields[$f]->getVar('field_main')) { |
||
| 111 | $fieldMain = $fieldName; // fieldMain = fields parameters main field |
||
| 112 | } |
||
| 113 | } |
||
| 114 | $ucfFieldName = ucfirst($fieldName); |
||
| 115 | } |
||
| 116 | $ccFieldId = $this->getCamelCase($fieldId, false, true); |
||
| 117 | $stuLpFieldName = mb_strtoupper($ccFieldId); |
||
| 118 | $ret = $this->getInclude(); |
||
| 119 | $ret .= $this->xc->getXcXoopsRequest($ccFieldId, (string)$fieldId, '', 'Int'); |
||
| 120 | $ret .= $this->phpcode->getPhpCodeCommentLine('Define Stylesheet'); |
||
| 121 | $ret .= $this->xc->getXcAddStylesheet(); |
||
| 122 | $redirectHeader = $this->xc->getXcRedirectHeader("{$stuModuleDirname}_URL . '/index.php'", '', '2', "{$language}NO{$stuLpFieldName}", false, "\t"); |
||
| 123 | $ret .= $this->phpcode->getPhpCodeConditions("empty(\${$ccFieldId})", '', '', $redirectHeader); |
||
| 124 | $ret .= $this->phpcode->getPhpCodeCommentLine('Verify that the article is published'); |
||
| 125 | if (false !== mb_strpos($fieldName, 'published')) { |
||
| 126 | $ret .= $this->phpcode->getPhpCodeCommentLine('Not yet', $fieldName); |
||
| 127 | $redirectHeader .= $this->getSimpleString('exit();'); |
||
| 128 | $ret .= $this->phpcode->getPhpCodeConditions("\${$ccFieldId}->getVar('{$fieldName}') == 0 || \${$ccFieldId}->getVar('{$fieldName}') > time()", '', '', $redirectHeader); |
||
| 129 | } |
||
| 130 | if (false !== mb_strpos($fieldName, 'expired')) { |
||
| 131 | $ret .= $this->phpcode->getPhpCodeCommentLine('Expired', $ucfFieldName); |
||
| 132 | $redirectHeader .= $this->getSimpleString('exit();'); |
||
| 133 | $ret .= $this->phpcode->getPhpCodeConditions("\${$ccFieldId}->getVar('{$fieldName}') != 0 && \${$ccFieldId}->getVar('{$fieldName}') < time()", '', '', $redirectHeader); |
||
| 134 | } |
||
| 135 | if (false !== mb_strpos($fieldName, 'date')) { |
||
| 136 | $ret .= $this->phpcode->getPhpCodeCommentLine('Date', $ucfFieldName); |
||
| 137 | $redirectHeader .= $this->getSimpleString('exit();'); |
||
| 138 | $ret .= $this->phpcode->getPhpCodeConditions("\${$ccFieldId}->getVar('{$fieldName}') != 0 && \${$ccFieldId}->getVar('{$fieldName}') < time()", '', '', $redirectHeader); |
||
| 139 | } |
||
| 140 | if (false !== mb_strpos($fieldName, 'time')) { |
||
| 141 | $ret .= $this->phpcode->getPhpCodeCommentLine('Time', $ucfFieldName); |
||
| 142 | $redirectHeader .= $this->getSimpleString('exit();'); |
||
| 143 | $ret .= $this->phpcode->getPhpCodeConditions("\${$ccFieldId}->getVar('{$fieldName}') != 0 && \${$ccFieldId}->getVar('{$fieldName}') < time()", '', '', $redirectHeader); |
||
| 144 | } |
||
| 145 | $ret .= $this->xc->getXcGet($tableName, $ccFieldId, '', true); |
||
| 146 | $gperm = $this->xc->getXcCheckRight('!$gpermHandler', "{$moduleDirname}_view", "\${$ccFieldId}->getVar('{$fieldId}')", '$groups', "\$GLOBALS['xoopsModule']->getVar('mid')", true); |
||
| 147 | $ret .= $this->phpcode->getPhpCodeCommentLine('Verify permissions'); |
||
| 148 | $noPerm = $this->xc->getXcRedirectHeader("{$stuModuleDirname}_URL . '/index.php'", '', '3', '_NOPERM', false, "\t"); |
||
| 149 | $noPerm .= $this->getSimpleString('exit();', "\t"); |
||
| 150 | $ret .= $this->phpcode->getPhpCodeConditions($gperm, '', '', $noPerm); |
||
| 151 | $ret .= $this->xc->getXcGetValues($tableName, $tableSoleName, '', true); |
||
| 152 | $contentForeach = $this->xc->getXcXoopsTplAppend('"{$k}"', '$v', "\t"); |
||
| 153 | $ret .= $this->phpcode->getPhpCodeForeach($tableSoleName, false, 'k', 'v', $contentForeach); |
||
| 154 | $ret .= $this->xc->getXcTplAssign('xoops_sitename', "\$GLOBALS['xoopsConfig']['sitename']"); |
||
| 155 | $getVar = $this->xc->getXcGetVar('', $tableSoleName, $fieldMain, true); |
||
| 156 | $stripTags = $this->phpcode->getPhpCodeStripTags('', $getVar . ' - ' . "{$language}PRINT" . ' - ' . "\$GLOBALS['xoopsModule']->name()", true); |
||
| 157 | $ret .= $this->xc->getXcTplAssign('xoops_pagetitle', $stripTags); |
||
| 158 | $ret .= $this->xc->getXcTplDisplay($tableName . '_print.tpl', '', false); |
||
| 159 | |||
| 160 | return $ret; |
||
| 161 | } |
||
| 182 |
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..