| Conditions | 19 |
| Paths | 1441 |
| Total Lines | 69 |
| Code Lines | 42 |
| 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 |
||
| 43 | public function export() |
||
| 44 | {
|
||
| 45 | foreach ($this->messages as $message) {
|
||
| 46 | $context = []; |
||
| 47 | if (isset($message[4])) {
|
||
| 48 | $context['trace'] = $message[4]; |
||
| 49 | } |
||
| 50 | |||
| 51 | if (isset($message[5])) {
|
||
| 52 | $context['memory'] = $message[5]; |
||
| 53 | } |
||
| 54 | |||
| 55 | if (isset($message[2])) {
|
||
| 56 | $context['category'] = $message[2]; |
||
| 57 | } |
||
| 58 | |||
| 59 | $text = $message[0]; |
||
| 60 | |||
| 61 | if (!is_string($text)) {
|
||
| 62 | // exceptions may not be serializable if in the call stack somewhere is a Closure |
||
| 63 | if ($text instanceof \Throwable || $text instanceof \Exception) {
|
||
| 64 | $text = (string)$text; |
||
| 65 | } elseif (\is_array($text)) {
|
||
| 66 | $ctx = $text; |
||
| 67 | if (isset($ctx['message'])) {
|
||
| 68 | $text = $ctx['message']; |
||
| 69 | unset($ctx['message']); |
||
| 70 | |||
| 71 | if (isset($ctx['exception'])) {
|
||
| 72 | $e = $ctx['exception']; |
||
| 73 | unset($ctx['exception']); |
||
| 74 | $context['exception'] = [ |
||
| 75 | 'message' => $e->getMessage(), |
||
| 76 | 'line' => $e->getLine(), |
||
| 77 | 'file' => $e->getFile(), |
||
| 78 | 'code' => $e->getCode(), |
||
| 79 | 'trace' => $e->getTrace() |
||
| 80 | ]; |
||
| 81 | } |
||
| 82 | foreach ($ctx as $k => $v) {
|
||
| 83 | $context[$k] = $v; |
||
| 84 | } |
||
| 85 | } else {
|
||
| 86 | $text = VarDumper::export($text); |
||
| 87 | } |
||
| 88 | } else {
|
||
| 89 | $text = VarDumper::export($text); |
||
| 90 | } |
||
| 91 | } |
||
| 92 | |||
| 93 | // If the user_id is not passed, dynamically set it from the user identity object |
||
| 94 | if (!isset($context['user_id'])) {
|
||
| 95 | $context['user_id'] = Yii::$app->has('user') && Yii::$app->user->id != null ? Yii::$app->user->id : 'system';
|
||
| 96 | } |
||
| 97 | |||
| 98 | // If the user_id of the event isn't the system, pre-load the policy number |
||
| 99 | if (!\in_array($context['user_id'], ['system', null])) {
|
||
| 100 | if (Yii::$app->has('user') && Yii::$app->user->id) {
|
||
| 101 | $model = Yii::$app->user->identity; |
||
| 102 | } else {
|
||
| 103 | $model = Yii::$app->user->identityClass::find()->where(['id' => $context['user_id']])->one(); |
||
| 104 | } |
||
| 105 | } |
||
| 106 | |||
| 107 | if (!isset($context['timestamp'])) {
|
||
| 108 | $context['timestamp'] = \microtime(true); |
||
| 109 | } |
||
| 110 | |||
| 111 | $this->getLogger()->log($this->_psrLevels[$message[1]], $text, $context); |
||
| 112 | } |
||
| 115 |
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