Completed
Push — master ( 5cd775...78bef9 )
by Jonathan
14:29 queued 04:27
created

UserCommand::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Uccello\Core\Console\Commands;
4
5
use Illuminate\Console\Command;
6
use App\User;
0 ignored issues
show
Bug introduced by
The type App\User was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use Hash;
8
use Uccello\Core\Models\Domain;
9
10
class UserCommand extends Command
11
{
12
    /**
13
     * The name and signature of the console command.
14
     *
15
     * @var string
16
     */
17
    protected $signature = 'uccello:user';
18
19
    /**
20
     * The console command description.
21
     *
22
     * @var string
23
     */
24
    protected $description = 'Create a new user';
25
26
    /**
27
     * Create a new command instance.
28
     *
29
     * @return void
30
     */
31
    public function __construct()
32
    {
33
        parent::__construct();
34
    }
35
36
    /**
37
     * Execute the console command.
38
     *
39
     * @return mixed
40
     */
41
    public function handle()
42
    {
43
        $username = $this->ask(trans('uccello::command.user.username'));
44
        $firstName = $this->ask(trans('uccello::command.user.first_name'));
45
        $lastName = $this->ask(trans('uccello::command.user.last_name'));
46
        $email = $this->ask(trans('uccello::command.user.email'));
47
        $password = $this->secret(trans('uccello::command.user.password'));
48
        $isAdmin = $this->ask(trans('uccello::command.user.is_admin'), true);
0 ignored issues
show
Bug introduced by
true of type true is incompatible with the type null|string expected by parameter $default of Illuminate\Console\Command::ask(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

48
        $isAdmin = $this->ask(trans('uccello::command.user.is_admin'), /** @scrutinizer ignore-type */ true);
Loading history...
49
50
        User::create([
51
            'username' => $username,
52
            'first_name' => $firstName,
53
            'last_name' => $lastName,
54
            'email' => $email,
55
            'password' => Hash::make($password),
56
            'is_admin' => $isAdmin,
57
            'domain_id' => Domain::first()->id
58
        ]);
59
60
        $this->info(trans('uccello::command.user.user_created'));
61
    }
62
}