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

LogClear::handle()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 0
cts 11
cp 0
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 7
nc 3
nop 0
crap 12
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