Completed
Push — master ( b56a59...34b930 )
by Avtandil
04:51
created

LogClear   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 36
ccs 0
cts 11
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 13 3
1
<?php
2
/*
3
 * This file is part of the Laravel Lodash package.
4
 *
5
 * (c) Avtandil Kikabidze aka LONGMAN <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
declare(strict_types=1);
11
12
namespace Longman\LaravelLodash\Commands;
13
14
use Illuminate\Console\Command;
15
use Illuminate\Filesystem\Filesystem;
16
17
class LogClear extends Command
18
{
19
    /**
20
     * The name and signature of the console command.
21
     *
22
     * @var string
23
     */
24
    protected $signature = 'log:clear';
25
26
    /**
27
     * The console command description.
28
     *
29
     * @var string
30
     */
31
    protected $description = 'Clear logs';
32
33
    /**
34
     * Execute the console command.
35
     *
36
     * @return mixed
37
     */
38
    public function handle()
39
    {
40
        $filesystem = app(Filesystem::class);
41
42
        $logFiles = $filesystem->glob(storage_path('logs/*.log'));
43
44
        foreach ($logFiles as $file) {
45
            $status = $filesystem->delete($file);
46
            if ($status) {
47
                $this->info('Successfully deleted: ' . $file);
48
            }
49
        }
50
    }
51
52
}
53