| Conditions | 12 |
| Paths | 26 |
| Total Lines | 65 |
| 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 |
||
| 140 | public function all() |
||
| 141 | { |
||
| 142 | $log = array(); |
||
| 143 | |||
| 144 | //make sure $file is set |
||
| 145 | $this->setFileAll(); |
||
| 146 | |||
| 147 | if (app('files')->size($this->file) > self::MAX_FILE_SIZE) { |
||
| 148 | return null; |
||
| 149 | } |
||
| 150 | |||
| 151 | $file = app('files')->get($this->file); |
||
| 152 | |||
| 153 | preg_match_all($this->pattern->getPattern('logs'), $file, $headings); |
||
| 154 | |||
| 155 | if (!is_array($headings)) { |
||
| 156 | return $log; |
||
| 157 | } |
||
| 158 | |||
| 159 | $this->log_data = preg_split($this->pattern->getPattern('logs'), $file); |
||
|
|
|||
| 160 | |||
| 161 | if ($this->log_data[0] < 1) { |
||
| 162 | array_shift($this->log_data); |
||
| 163 | } |
||
| 164 | |||
| 165 | foreach ($headings as $h) { |
||
| 166 | for ($i = 0, $j = count($h); $i < $j; $i++) { |
||
| 167 | foreach ($this->level->all() as $key => $level) { |
||
| 168 | if (strpos(strtolower($h[$i]), '.' . $level) || strpos(strtolower($h[$i]), $level . ':')) { |
||
| 169 | |||
| 170 | preg_match($this->pattern->getPattern('current_log', |
||
| 171 | 0) . $level . $this->pattern->getPattern('current_log', 1), $h[$i], $current); |
||
| 172 | if (!isset($current[4])) { |
||
| 173 | continue; |
||
| 174 | } |
||
| 175 | $log[] = $this->getArrayLog([ |
||
| 176 | 'index' => $i, |
||
| 177 | 'current' => $current, |
||
| 178 | 'level' => $level, |
||
| 179 | 'key' => $key, |
||
| 180 | 'line' => '' |
||
| 181 | ]); |
||
| 182 | } |
||
| 183 | } |
||
| 184 | } |
||
| 185 | } |
||
| 186 | |||
| 187 | if (empty($log)) { |
||
| 188 | |||
| 189 | $lines = explode(PHP_EOL, $file); |
||
| 190 | $log = []; |
||
| 191 | |||
| 192 | foreach ($lines as $key => $line) { |
||
| 193 | $log[] = $this->getArrayLog([ |
||
| 194 | 'index' => '', |
||
| 195 | 'current' => [], |
||
| 196 | 'level' => '', |
||
| 197 | 'key' => $key, |
||
| 198 | 'line' => $line |
||
| 199 | ]); |
||
| 200 | } |
||
| 201 | } |
||
| 202 | |||
| 203 | return array_reverse($log); |
||
| 204 | } |
||
| 205 | |||
| 275 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..