Conditions | 17 |
Paths | 3889 |
Total Lines | 62 |
Code Lines | 39 |
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 |
||
75 | public function format(array $record) |
||
76 | { |
||
77 | $record = parent::format($record); |
||
78 | |||
79 | if (!isset($record['datetime'], $record['message'], $record['level'])) { |
||
80 | throw new \InvalidArgumentException('The record should at least contain datetime, message and level keys, '.var_export($record, true).' given'); |
||
81 | } |
||
82 | |||
83 | $message = new Message(); |
||
84 | $message |
||
85 | ->setTimestamp($record['datetime']) |
||
86 | ->setShortMessage((string) $record['message']) |
||
87 | ->setHost($this->systemName) |
||
88 | ->setLevel($this->logLevels[$record['level']]); |
||
89 | |||
90 | // message length + system name length + 200 for padding / metadata |
||
91 | $len = 200 + strlen((string) $record['message']) + strlen($this->systemName); |
||
92 | |||
93 | if ($len > $this->maxLength) { |
||
94 | $message->setShortMessage(substr($record['message'], 0, $this->maxLength)); |
||
95 | } |
||
96 | |||
97 | if (isset($record['channel'])) { |
||
98 | $message->setFacility($record['channel']); |
||
99 | } |
||
100 | if (isset($record['extra']['line'])) { |
||
101 | $message->setLine($record['extra']['line']); |
||
102 | unset($record['extra']['line']); |
||
103 | } |
||
104 | if (isset($record['extra']['file'])) { |
||
105 | $message->setFile($record['extra']['file']); |
||
106 | unset($record['extra']['file']); |
||
107 | } |
||
108 | |||
109 | foreach ($record['extra'] as $key => $val) { |
||
110 | $val = is_scalar($val) || null === $val ? $val : $this->toJson($val); |
||
111 | $len = strlen($this->extraPrefix . $key . $val); |
||
112 | if ($len > $this->maxLength) { |
||
113 | $message->setAdditional($this->extraPrefix . $key, substr($val, 0, $this->maxLength)); |
||
114 | break; |
||
115 | } |
||
116 | $message->setAdditional($this->extraPrefix . $key, $val); |
||
117 | } |
||
118 | |||
119 | foreach ($record['context'] as $key => $val) { |
||
120 | $val = is_scalar($val) || null === $val ? $val : $this->toJson($val); |
||
121 | $len = strlen($this->contextPrefix . $key . $val); |
||
122 | if ($len > $this->maxLength) { |
||
123 | $message->setAdditional($this->contextPrefix . $key, substr($val, 0, $this->maxLength)); |
||
124 | break; |
||
125 | } |
||
126 | $message->setAdditional($this->contextPrefix . $key, $val); |
||
127 | } |
||
128 | |||
129 | if (null === $message->getFile() && isset($record['context']['exception']['file'])) { |
||
130 | if (preg_match("/^(.+):([0-9]+)$/", $record['context']['exception']['file'], $matches)) { |
||
131 | $message->setFile($matches[1]); |
||
132 | $message->setLine($matches[2]); |
||
133 | } |
||
134 | } |
||
135 | |||
136 | return $message; |
||
137 | } |
||
139 |
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