| Conditions | 12 |
| Paths | 26 |
| Total Lines | 53 |
| 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($i, $current, $level, $key, ''); |
||
| 176 | } |
||
| 177 | } |
||
| 178 | } |
||
| 179 | } |
||
| 180 | |||
| 181 | if (empty($log)) { |
||
| 182 | |||
| 183 | $lines = explode(PHP_EOL, $file); |
||
| 184 | $log = []; |
||
| 185 | |||
| 186 | foreach ($lines as $key => $line) { |
||
| 187 | $log[] = $this->getArrayLog('', '', '', $key, $line); |
||
| 188 | } |
||
| 189 | } |
||
| 190 | |||
| 191 | return array_reverse($log); |
||
| 192 | } |
||
| 193 | |||
| 259 | } |
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..