DeleteUserCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 40
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 18 3
1
<?php
2
3
namespace Luilliarcec\UserCommands\Commands;
4
5
6
class DeleteUserCommand extends UserCommand
7
{
8
    /**
9
     * The name and signature of the console command.
10
     *
11
     * @var string
12
     */
13
    protected $signature = 'user:delete
14
                            {value : Get user for a value (by email, id)}
15
                            {field? : Field to search by}
16
                            {--force}';
17
18
    /**
19
     * The console command description.
20
     *
21
     * @var string
22
     */
23
    protected $description = 'Delete a user';
24
25
    /**
26
     * Execute the console command.
27
     */
28
    public function handle()
29
    {
30
        $user = $this->getUserModel();
31
32
        if (is_null($user)) {
33
            $this->error('Oops, the user was not found!');
34
            return 1;
35
        }
36
37
        if ($this->option('force')) {
38
            $user->forceDelete();
39
        } else {
40
            $user->delete();
41
        }
42
43
        $this->info('User deleted successfully!');
44
45
        return 0;
46
    }
47
}
48