UserCreate::getOptions()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 2
cts 2
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
crap 1
1
<?php
2
3
namespace PiFinder\Console\Commands;
4
5
use Illuminate\Console\Command;
6
use PiFinder\Services\Registrar;
7
use Symfony\Component\Console\Input\InputOption;
8
use Symfony\Component\Console\Input\InputArgument;
9
10
class UserCreate extends Command
11
{
12
    /**
13
     * The console command name.
14
     *
15
     * @var string
16
     */
17
    protected $name = 'user:create';
18
19
    /**
20
     * The console command description.
21
     *
22
     * @var string
23
     */
24
    protected $description = 'Create a user.';
25
26
    /**
27
     * The registrar implementation.
28
     *
29
     * @var Registrar
30
     */
31
    private $registrar;
32
33
    /**
34
     * Create a new command instance.
35
     *
36
     * @param Registrar $registrar
37
     */
38 6
    public function __construct(Registrar $registrar)
39
    {
40 6
        parent::__construct();
41
42 6
        $this->registrar = $registrar;
43 6
    }
44
45
    /**
46
     * Execute the console command.
47
     *
48
     * @return mixed
49
     */
50 1
    public function fire()
51
    {
52 1
        $email = $this->argument('email');
53 1
        $password = $this->option('password');
54 1
        $password_confirmation = $this->option('password_confirmation');
55
56 1
        if (! $password) {
57
            $password = $this->secret('What password should the user have?');
58
        }
59
60 1
        if (! $password_confirmation) {
61
            $password_confirmation = $this->secret('Please confirm the password.');
62
        }
63
64 1
        $this->registrar->create(compact('email', 'password', 'password_confirmation'));
65 1
    }
66
67
    /**
68
     * Get the console command arguments.
69
     *
70
     * @return array
71
     */
72 6
    protected function getArguments()
73
    {
74
        return [
75 6
            ['email', InputArgument::REQUIRED, 'The email address of the user.'],
76
        ];
77
    }
78
79
    /**
80
     * Get the console command options.
81
     *
82
     * @return array
83
     */
84 6
    protected function getOptions()
85
    {
86
        return [
87 6
            ['password', null, InputOption::VALUE_OPTIONAL, 'The password for the user.', null],
88
            ['password_confirmation', null, InputOption::VALUE_OPTIONAL, 'Password confirmation.', null],
89
        ];
90
    }
91
}
92