| Conditions | 27 | 
| Paths | 202 | 
| Total Lines | 118 | 
| Code Lines | 77 | 
| 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 | ||
| 115 | final public function __execute($method, $arguments, $filepath) | ||
| 116 |     { | ||
| 117 | $result = null; | ||
| 118 | |||
| 119 |         try { | ||
| 120 | |||
| 121 | |||
| 122 | // TODO xmlのidにselect,update等が指定されると、メソッド実行の判定からのmethod_missingループになるバグ | ||
| 123 | // | ||
| 124 |             if (preg_match('/^(?:select|(?:dele|upda)te|insert)$/', $method)) { | ||
| 125 | $sql = $arguments[0]; | ||
| 126 | $bind = null; | ||
| 127 |                 if (array_key_exists(1, $arguments)) { | ||
| 128 | $bind = $arguments[1]; | ||
| 129 | } | ||
| 130 | |||
| 131 |                 if (is_string($sql)) { | ||
| 132 |                     if ($method !== 'select' && $this->isAutoCommit) { | ||
| 133 | $this->manager->beginTransaction(Connection::TRANSACTION_READ_COMMITTED); | ||
| 134 | } | ||
| 135 |                     if (is_array($bind)) { | ||
| 136 |                         $result = $this->manager->query($sql, $bind)->{$method}(); | ||
| 137 |                     } else { | ||
| 138 |                         $result = $this->manager->query($sql)->{$method}(); | ||
| 139 | } | ||
| 140 |                 } else { | ||
| 141 |                     throw new DatabaseException("Invalid SQL or bind parameters: " . $sql .", " . strval($bind)); | ||
| 142 | } | ||
| 143 |             } else { | ||
| 144 | $bind = null; | ||
| 145 |                 if (array_key_exists(0, $arguments)) { | ||
| 146 | $bind = $arguments[0]; | ||
| 147 | } | ||
| 148 | |||
| 149 | $trace = debug_backtrace(); | ||
| 150 | $modelMethod = null; | ||
| 151 |                 for ($i = 0; $i < count($trace); $i++) { | ||
| 152 |                     if ($this->inArray($trace[$i]["function"], ["__call", "__execute"])) { | ||
| 153 | continue; | ||
| 154 | } | ||
| 155 | |||
| 156 |                     if ($trace[$i]["function"] !== null) { | ||
| 157 | $modelMethod = $trace[$i]["function"]; | ||
| 158 | break; | ||
| 159 | } | ||
| 160 | } | ||
| 161 | |||
| 162 | $namespace = substr($this->getNamespace($filepath), 1); | ||
| 163 | $queryKey = $namespace . "\\" . basename($filepath, ".php") . "#" . $modelMethod; | ||
| 164 | $xpath = "//mapper[@namespace='$namespace']/*[@id='$method']"; | ||
| 165 | |||
| 166 | $queryInfo = $this->container->queryInfo; | ||
| 167 | $queryList = $queryInfo($queryKey, $xpath); | ||
| 168 | $query = array_shift($queryList); | ||
| 169 | |||
| 170 |                 if ($query === null) { | ||
| 171 |                     throw new DatabaseException("SQL statement can't getting from xml file: " . $modelMethod); | ||
| 172 | } | ||
| 173 | |||
| 174 | $sql = $query["sql"]; | ||
| 175 | $method = $query["method"]; | ||
| 176 | $entityClassPath = $query["entity"]; | ||
| 177 | |||
| 178 |                 if ($entityClassPath !== null) { | ||
| 179 |                     if (!class_exists($entityClassPath)) { | ||
| 180 |                         throw new DatabaseException("Entity classpath is not found: " . $entityClassPath); | ||
| 181 | } | ||
| 182 | |||
| 183 |                     switch ($method) { | ||
| 184 | case "select": | ||
| 185 |                             if (is_string($sql)) { | ||
| 186 |                                 if (is_array($bind)) { | ||
| 187 | $result = $this->manager->query($sql, $bind)->select()->toEntity($entityClassPath); | ||
| 188 |                                 } else { | ||
| 189 | $result = $this->manager->query($sql)->select()->toEntity($entityClassPath); | ||
| 190 | } | ||
| 191 |                             } else { | ||
| 192 | $errorMessage = "Invalid SQL or bind parameters: " . $sql; | ||
| 193 |                                 if (is_array($bind)) { | ||
| 194 | $errorMessage .= ", " . strval($bind); | ||
| 195 | } | ||
| 196 | |||
| 197 | throw new DatabaseException($errorMessage); | ||
| 198 | } | ||
| 199 | |||
| 200 | break; | ||
| 201 | case "insert": | ||
| 202 | case "update": | ||
| 203 | case "delete": | ||
| 204 | // Not implement | ||
| 205 |                             throw new DatabaseException("Entity mapping is select only."); | ||
| 206 | } | ||
| 207 |                 } else { | ||
| 208 |                     if (is_string($sql)) { | ||
| 209 |                         if ($method !== 'select' && $this->isAutoCommit) { | ||
| 210 | $this->manager->beginTransaction(Connection::TRANSACTION_READ_COMMITTED); | ||
| 211 | } | ||
| 212 |                         if (is_array($bind)) { | ||
| 213 |                             $result = $this->manager->query($sql, $bind)->{$method}(); | ||
| 214 |                         } else { | ||
| 215 |                             $result = $this->manager->query($sql)->{$method}(); | ||
| 216 | } | ||
| 217 |                     } else { | ||
| 218 | $errorMessage = "Invalid SQL or bind parameters: " . $sql; | ||
| 219 |                         if (is_array($bind)) { | ||
| 220 | $errorMessage .= ", " . strval($bind); | ||
| 221 | } | ||
| 222 | |||
| 223 | throw new DatabaseException($errorMessage); | ||
| 224 | } | ||
| 225 | } | ||
| 226 | } | ||
| 227 | |||
| 228 | return $result; | ||
| 229 |         } catch (DatabaseException $e) { | ||
| 230 | $this->manager->rollback(); | ||
| 231 | $this->manager->disconnect(); | ||
| 232 | throw $e; | ||
| 233 | } | ||
| 273 | 
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