UserDelete::fire()   A
last analyzed

Complexity

Conditions 2
Paths 4

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 8
cts 8
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 8
nc 4
nop 0
crap 2
1
<?php
2
3
namespace PiFinder\Console\Commands;
4
5
use PiFinder\User;
6
use Illuminate\Console\Command;
7
use Symfony\Component\Console\Input\InputArgument;
8
use Illuminate\Database\Eloquent\ModelNotFoundException;
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 1
    public function fire()
32
    {
33 1
        $email = $this->argument('email');
34
35
        try {
36 1
            $user = User::whereEmail($email)->firstOrFail();
37 1
            $user->delete();
38
39 1
            $this->info('User deleted.');
40 1
        } catch (ModelNotFoundException $e) {
41 1
            $this->error('Did not find a user with the given email address');
42
        }
43 1
    }
44
45
    /**
46
     * Get the console command arguments.
47
     *
48
     * @return array
49
     */
50 6
    protected function getArguments()
51
    {
52
        return [
53 6
            ['email', InputArgument::REQUIRED, 'The email address of the user.'],
54
        ];
55
    }
56
}
57