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

UserDelete::getArguments()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 6
ccs 3
cts 3
cp 1
crap 1
rs 9.4285
c 2
b 0
f 0
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