RotateFileCommand   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
eloc 9
c 1
b 0
f 1
dl 0
loc 20
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 10 2
1
<?php
2
3
namespace Cesargb\LaravelLog\Commands;
4
5
use Cesargb\LaravelLog\Rotate;
6
use Illuminate\Console\Command;
7
8
class RotateFileCommand extends Command
9
{
10
    protected $signature = 'rotate:files
11
                                        {--f|file=* : Files to rotate}
12
                                        {--c|compress=true : Compress the file rotated}
13
                                        {--m|max-files=5 : Max files rotated}
14
                                        {--d|dir= : Dir where archive the file rotated}';
15
16
    protected $description = 'Rotate files';
17
18
    public function handle()
19
    {
20
        foreach ($this->option('file') as $filename) {
21
            $this->line('Rotate file '.basename($filename).': ');
22
23
            $rotate = new Rotate();
24
25
            $rotate->file($filename, [
26
                'files' => config('rotate.log_max_files', 366),
27
                'compress' => config('rotate.log_compress_files', true),
28
                // 'then' => function () {
29
                //     $this->line('<info>ok</>');
30
                // },
31
                // 'catch' => function ($error) {
32
                //     $this->error('<comment>failed: '.$error->getMessage().'</>');
33
                // },
34
            ]);
35
        }
36
    }
37
}
38