DataIncineratorCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 10
c 1
b 0
f 0
dl 0
loc 25
ccs 10
cts 10
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A handle() 0 8 2
1
<?php
2
3
4
namespace VictorAvelar\Geld\Commands;
5
6
use DateTime;
7
use Exception;
8
use Illuminate\Console\Command;
9
use Illuminate\Support\Facades\Log;
10
use VictorAvelar\Geld\Models\CurrencyHistory;
11
12
class DataIncineratorCommand extends Command
13
{
14
    protected $signature = 'geld:incinerate';
15
16
    protected $description = 'Removes records older than the specified incineration threshold';
17
18
    /**
19
     * DataIncineratorCommand constructor.
20
     */
21 15
    public function __construct()
22
    {
23 15
        parent::__construct();
24 15
    }
25
26
    /**
27
     * @throws Exception
28
     */
29 3
    public function handle()
30
    {
31 3
        if (config('geld.incinerate')) {
32 3
            $incinerate = '@'.strtotime('-'.config('geld.incinerate_after'));
33 3
            $edge = new DateTime($incinerate);
34 3
            CurrencyHistory::where('created_at', '<', $edge)
35 3
                ->forceDelete();
36 3
            Log::info("Data incinerated successfully");
37
        }
38 3
    }
39
}
40