CreateAdminCommand   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 36
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 25 2
1
<?php
2
3
namespace App\Containers\User\UI\CLI\Commands;
4
5
use Apiato\Core\Foundation\Facades\Apiato;
6
use App\Ship\Parents\Commands\ConsoleCommand;
7
use App\Ship\Transporters\DataTransporter;
8
9
/**
10
 * Class CreateAdminCommand
11
 *
12
 * @author  Johannes Schobel <[email protected]>
13
 */
14
class CreateAdminCommand extends ConsoleCommand
15
{
16
17
    protected $signature = 'apiato:create:admin';
18
19
    protected $description = 'Create a new User with the ADMIN role';
20
21
    /**
22
     * @void
23
     */
24
    public function handle()
25
    {
26
        $username = $this->ask('Enter the username for this user');
27
        $email = $this->ask('Enter the email address of this user');
28
        $password = $this->secret('Enter the password for this user');
29
        $password_confirmation = $this->secret('Please confirm the password');
30
31
        if ($password != $password_confirmation) {
32
            $this->error('Passwords do not match - exiting!');
33
            return;
34
        }
35
36
        // ok, we have everything - lets create the user
37
        // we therefore simply create a Transporter
38
        $dataTransporter = new DataTransporter([
39
            'name' => $username,
40
            'email' => $email,
41
            'password' => $password,
42
        ]);
43
44
        // and then call respective Action
45
        $user = Apiato::call('[email protected]', [$dataTransporter]);
0 ignored issues
show
Unused Code introduced by Johannes Schobel
$user is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
46
47
        $this->info('Admin ' . $email . ' was successfully created');
48
    }
49
}
50