AdminCreateCommand::configure()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 1

Importance

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