| Conditions | 29 |
| Paths | 544 |
| Total Lines | 93 |
| Code Lines | 67 |
| 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 declare(strict_types=1); |
||
| 126 | public function store() |
||
| 127 | { |
||
| 128 | $myts = MyTextSanitizer::getInstance(); |
||
| 129 | $title = ''; |
||
| 130 | $imgurl = ''; |
||
| 131 | if (isset($this->topic_title) && '' !== $this->topic_title) { |
||
| 132 | $title = $GLOBALS['xoopsDB']->escape($this->topic_title); |
||
| 133 | } |
||
| 134 | if (isset($this->topic_imgurl) && '' !== $this->topic_imgurl) { |
||
| 135 | $imgurl = $GLOBALS['xoopsDB']->escape($this->topic_imgurl); |
||
| 136 | } |
||
| 137 | if (!isset($this->topic_pid) || !\is_numeric($this->topic_pid)) { |
||
| 138 | $this->topic_pid = 0; |
||
| 139 | } |
||
| 140 | if (empty($this->topic_id)) { |
||
| 141 | $this->topic_id = $this->db->genId($this->table . '_topic_id_seq'); |
||
| 142 | $sql = \sprintf("INSERT INTO `%s` (topic_id, topic_pid, topic_imgurl, topic_title) VALUES (%u, %u, '%s', '%s')", $this->table, $this->topic_id, $this->topic_pid, $imgurl, $title); |
||
| 143 | } else { |
||
| 144 | $sql = \sprintf("UPDATE `%s` SET topic_pid = %u, topic_imgurl = '%s', topic_title = '%s' WHERE topic_id = %u", $this->table, $this->topic_pid, $imgurl, $title, $this->topic_id); |
||
| 145 | } |
||
| 146 | if (!$result = $this->db->query($sql)) { |
||
| 147 | \trigger_error("Query Failed! SQL: $sql- Error: " . $this->db->error(), E_USER_ERROR); |
||
| 148 | } |
||
| 149 | if ($this->use_permission) { |
||
| 150 | if (empty($this->topic_id)) { |
||
| 151 | $this->topic_id = $this->db->getInsertId(); |
||
| 152 | } |
||
| 153 | $xt = new \XoopsTree($this->table, 'topic_id', 'topic_pid'); |
||
| 154 | $parent_topics = $xt->getAllParentId($this->topic_id); |
||
| 155 | if (!empty($this->m_groups) && \is_array($this->m_groups)) { |
||
| 156 | foreach ($this->m_groups as $m_g) { |
||
| 157 | $moderate_topics = XoopsPerms::getPermitted($this->mid, 'ModInTopic', $m_g); |
||
| 158 | $add = true; |
||
| 159 | // only grant this permission when the group has this permission in all parent topics of the created topic |
||
| 160 | foreach ($parent_topics as $p_topic) { |
||
| 161 | if (!\in_array($p_topic, $moderate_topics, true)) { |
||
| 162 | $add = false; |
||
| 163 | continue; |
||
| 164 | } |
||
| 165 | } |
||
| 166 | if ($add) { |
||
| 167 | $xp = new XoopsPerms(); |
||
| 168 | $xp->setModuleId($this->mid); |
||
| 169 | $xp->setName('ModInTopic'); |
||
| 170 | $xp->setItemId($this->topic_id); |
||
| 171 | $xp->store(); |
||
| 172 | $xp->addGroup($m_g); |
||
| 173 | } |
||
| 174 | } |
||
| 175 | } |
||
| 176 | if (!empty($this->s_groups) && \is_array($this->s_groups)) { |
||
| 177 | foreach ($this->s_groups as $s_g) { |
||
| 178 | $submit_topics = XoopsPerms::getPermitted($this->mid, 'SubmitInTopic', $s_g); |
||
| 179 | $add = true; |
||
| 180 | foreach ($parent_topics as $p_topic) { |
||
| 181 | if (!\in_array($p_topic, $submit_topics, true)) { |
||
| 182 | $add = false; |
||
| 183 | continue; |
||
| 184 | } |
||
| 185 | } |
||
| 186 | if ($add) { |
||
| 187 | $xp = new XoopsPerms(); |
||
| 188 | $xp->setModuleId($this->mid); |
||
| 189 | $xp->setName('SubmitInTopic'); |
||
| 190 | $xp->setItemId($this->topic_id); |
||
| 191 | $xp->store(); |
||
| 192 | $xp->addGroup($s_g); |
||
| 193 | } |
||
| 194 | } |
||
| 195 | } |
||
| 196 | if (!empty($this->r_groups) && \is_array($this->r_groups)) { |
||
| 197 | foreach ($this->r_groups as $r_g) { |
||
| 198 | $read_topics = XoopsPerms::getPermitted($this->mid, 'ReadInTopic', $r_g); |
||
| 199 | $add = true; |
||
| 200 | foreach ($parent_topics as $p_topic) { |
||
| 201 | if (!\in_array($p_topic, $read_topics, true)) { |
||
| 202 | $add = false; |
||
| 203 | continue; |
||
| 204 | } |
||
| 205 | } |
||
| 206 | if ($add) { |
||
| 207 | $xp = new XoopsPerms(); |
||
| 208 | $xp->setModuleId($this->mid); |
||
| 209 | $xp->setName('ReadInTopic'); |
||
| 210 | $xp->setItemId($this->topic_id); |
||
| 211 | $xp->store(); |
||
| 212 | $xp->addGroup($r_g); |
||
| 213 | } |
||
| 214 | } |
||
| 215 | } |
||
| 216 | } |
||
| 217 | |||
| 218 | return true; |
||
| 219 | } |
||
| 425 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths