AdminCreateCommand   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Test Coverage

Coverage 55%

Importance

Changes 2
Bugs 0 Features 2
Metric Value
wmc 2
c 2
b 0
f 2
lcom 0
cbo 6
dl 0
loc 35
ccs 11
cts 20
cp 0.55
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 13 1
A execute() 0 12 1
1
<?php
2
3
namespace AppBundle\Command;
4
5
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
6
use Symfony\Component\Console\Input\InputArgument;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Output\OutputInterface;
9
10
/**
11
 * Class AdminCreateCommand
12
 * @package AppBundle\Command
13
 */
14
class AdminCreateCommand extends ContainerAwareCommand
15
{
16
    /**
17
     * {@inheritdoc}
18
     */
19 27
    protected function configure()
20
    {
21 27
        $this
22 27
            ->setName('app:admin_create')
23 27
            ->setDescription('Create admin user')
24 27
            ->setDefinition(array(
25 27
                new InputArgument('email', InputArgument::REQUIRED, 'The email'),
26 27
                new InputArgument('password', InputArgument::REQUIRED, 'The password'),
27 27
                new InputArgument('firstName', InputArgument::REQUIRED, 'The first name'),
28 27
                new InputArgument('lastName', InputArgument::REQUIRED, 'The last name')
29 27
            ));
30
31 27
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    protected function execute(InputInterface $input, OutputInterface $output)
37
    {
38
        $email      = $input->getArgument('email');
39
        $password   = $input->getArgument('password');
40
        $firstName  = $input->getArgument('firstName');
41
        $lastName   = $input->getArgument('lastName');
42
43
        $this->getContainer()->get('app.admin.creator')
44
             ->create($email, $password, $firstName, $lastName);
45
46
        $output->writeln(sprintf('User <comment>%s</comment> was created/updated', $firstName.' '.$lastName));
47
    }
48
}
49