ShortenerCommand   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 66.67%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 29
rs 10
c 0
b 0
f 0
ccs 6
cts 9
cp 0.6667

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 12 2
1
<?php
2
3
namespace MuhamedDidovic\Shortener\Console;
4
5
use DB;
6
use Exception;
7
use Illuminate\Console\Command;
8
use MuhamedDidovic\Shortener\Models\Link;
9
10
/**
11
 * Class Shortener.
12
 */
13
class ShortenerCommand extends Command
14
{
15
    /**
16
     * The name and signature of the console command.
17
     *
18
     * @var string
19
     */
20
    protected $signature = 'shortener:clean';
21
22
    /**
23
     * The console command description.
24
     *
25
     * @var string
26
     */
27
    protected $description = 'Delete rows where column "code" is null';
28
29 2
    public function handle()
30
    {
31 2
        DB::beginTransaction();
32
        try {
33 2
            $links = Link::whereNull('code')->delete();
34 2
            $this->info('Deleted rows:'.$links);
35 2
            DB::commit();
36
        } catch (Exception $e) {
37
            DB::rollBack();
38
            $this->error($e);
39
        }
40 2
    }
41
}
42