Passed
Push — develop ( 8ccef8...5801e1 )
by Francisco
06:48
created

ResetEnrollments   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 43
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 14 1
A __construct() 0 3 1
1
<?php
2
3
namespace App\Console\Commands;
4
5
use App\Judite\Models\Shift;
6
use Illuminate\Console\Command;
7
use App\Judite\Models\Enrollment;
8
use Illuminate\Support\Facades\DB;
9
use App\Judite\Contracts\Registry\ExchangeRegistry;
10
11
class ResetEnrollments extends Command
12
{
13
    /**
14
     * The name and signature of the console command.
15
     *
16
     * @var string
17
     */
18
    protected $signature = 'reset:enrollments';
19
20
    /**
21
     * The console command description.
22
     *
23
     * @var string
24
     */
25
    protected $description = 'Delete existing enrollments and all data associated to them.';
26
27
    /**
28
     * Create a new command instance.
29
     */
30
    public function __construct()
31
    {
32
        parent::__construct();
33
    }
34
35
    /**
36
     * Execute the console command.
37
     *
38
     * @return mixed
39
     */
40
    public function handle()
41
    {
42
        DB::transaction(function () {
43
            // Delete exchange registry.
44
            resolve(ExchangeRegistry::class)->truncate();
45
46
            // Delete exchanges.
47
            Exchange::query()->delete();
0 ignored issues
show
Bug introduced by
The type App\Console\Commands\Exchange was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
48
49
            // Delete enrollments
50
            Enrollment::query()->delete();
51
52
            // Delete all shifts.
53
            Shift::query()->delete();
54
        });
55
    }
56
}
57