Completed
Push — master ( df4800...ec8b14 )
by Manuel
03:30
created

UserDelete::fire()   A

Complexity

Conditions 2
Paths 4

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 13
ccs 0
cts 8
cp 0
rs 9.4285
cc 2
eloc 8
nc 4
nop 0
crap 6
1
<?php
2
3
namespace PiFinder\Console\Commands;
4
5
use Illuminate\Console\Command;
6
use Illuminate\Database\Eloquent\ModelNotFoundException;
7
use PiFinder\User;
8
use Symfony\Component\Console\Input\InputArgument;
9
10
class UserDelete extends Command
11
{
12
    /**
13
     * The console command name.
14
     *
15
     * @var string
16
     */
17
    protected $name = 'user:delete';
18
19
    /**
20
     * The console command description.
21
     *
22
     * @var string
23
     */
24
    protected $description = 'Delete a user.';
25
26
    /**
27
     * Execute the console command.
28
     *
29
     * @return mixed
30
     */
31
    public function fire()
32
    {
33
        $email = $this->argument('email');
34
35
        try {
36
            $user = User::whereEmail($email)->firstOrFail();
37
            $user->delete();
38
39
            $this->info('User deleted.');
40
        } catch (ModelNotFoundException $e) {
41
            $this->error('Did not find a user with the given email address');
42
        }
43
    }
44
45
    /**
46
     * Get the console command arguments.
47
     *
48
     * @return array
49
     */
50 4
    protected function getArguments()
51
    {
52
        return [
53 4
            ['email', InputArgument::REQUIRED, 'The email address of the user.'],
54 4
        ];
55
    }
56
}
57