| Conditions | 11 |
| Paths | 32 |
| Total Lines | 29 |
| Code Lines | 22 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
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 |
||
| 53 | public function log(string $level, string $message, array $context = []): void |
||
| 54 | { |
||
| 55 | $template = $this->getUserTemplate(); |
||
| 56 | $module = ArrayHelper::remove($context, 'module'); |
||
| 57 | if ($module !== null) { |
||
| 58 | Seaslog::setLogger($this->appName . '_' . $module); |
||
| 59 | } |
||
| 60 | isset($template['%Q']) && Seaslog::setRequestID($template['%Q']); |
||
| 61 | foreach (array_filter([ |
||
| 62 | SEASLOG_REQUEST_VARIABLE_DOMAIN_PORT => isset($template['%D']) ? $template['%D'] : null, |
||
| 63 | SEASLOG_REQUEST_VARIABLE_REQUEST_URI => isset($template['%R']) ? $template['%R'] : null, |
||
| 64 | SEASLOG_REQUEST_VARIABLE_REQUEST_METHOD => isset($template['%m']) ? $template['%m'] : null, |
||
| 65 | SEASLOG_REQUEST_VARIABLE_CLIENT_IP => isset($template['%I']) ? $template['%I'] : null |
||
| 66 | ]) as $key => $value) { |
||
| 67 | Seaslog::setRequestVariable($key, $value); |
||
| 68 | } |
||
| 69 | if (!empty($template = ArrayHelper::remove($context, 'template', []) ?? ArrayHelper::remove($template, '%A', |
||
| 70 | []))) { |
||
| 71 | switch ($this->customerType) { |
||
| 72 | case AbstractConfig::TYPE_JSON: |
||
| 73 | $template = json_encode($template, JSON_UNESCAPED_UNICODE); |
||
| 74 | break; |
||
| 75 | case AbstractConfig::TYPE_FIELD: |
||
| 76 | $template = implode($this->split, $template); |
||
| 77 | } |
||
| 78 | $message = $template . $this->split . $message; |
||
| 79 | } |
||
| 80 | Seaslog::$level($message); |
||
| 81 | $this->flush(); |
||
| 82 | } |
||
| 104 | } |
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