RotateCommand   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 6
eloc 13
c 1
b 0
f 1
dl 0
loc 36
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A rotateFile() 0 5 1
A rotateLaravelLogs() 0 6 2
A handle() 0 5 1
A rotareForeingFiles() 0 6 2
1
<?php
2
3
namespace Cesargb\LaravelLog\Commands;
4
5
use Cesargb\LaravelLog\Helpers\Log as LogHelper;
6
use Cesargb\LaravelLog\Rotate as LaravelLogRotate;
7
use Illuminate\Console\Command;
8
9
class RotateCommand extends Command
10
{
11
    protected $signature = 'rotate:logs';
12
13
    protected $description = 'Rotate logs of Laravel';
14
15
    public function handle()
16
    {
17
        $this->rotateLaravelLogs();
18
19
        $this->rotareForeingFiles();
20
    }
21
22
    protected function rotateLaravelLogs()
23
    {
24
        foreach (LogHelper::getLaravelLogFiles() as $file) {
25
            $this->line('Rotate file: '.$file);
26
27
            $this->rotateFile($file);
28
        }
29
    }
30
31
    protected function rotareForeingFiles()
32
    {
33
        foreach (config('rotate.foreign_files', []) as $file) {
34
            $this->line('Rotate file: '.$file);
35
36
            $this->rotateFile($file);
37
        }
38
    }
39
40
    protected function rotateFile(string $filename)
41
    {
42
        $rotation = new LaravelLogRotate();
43
44
        $rotation->file($filename);
45
    }
46
}
47