Passed
Push — master ( 99e9d5...233c5a )
by Derek Stephen
09:09
created

ScopeCreateCommand::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
namespace OAuth\Command;
4
5
use Del\Service\UserService;
6
use OAuth\Client;
7
use OAuth\Repository\ScopeRepository;
8
use OAuth\Scope;
9
use OAuth\Service\ClientService;
10
use OAuth\OAuthUser as User;
11
use Symfony\Component\Console\Command\Command;
12
use Symfony\Component\Console\Input\InputInterface;
13
use Symfony\Component\Console\Output\OutputInterface;
14
use Symfony\Component\Console\Question\ChoiceQuestion;
15
use Symfony\Component\Console\Question\ConfirmationQuestion;
16
use Symfony\Component\Console\Question\Question;
17
18
/**
19
 * Class ClientCommand
20
 * @package OAuth\Command
21
 */
22
class ScopeCreateCommand extends Command
23
{
24
    /**
25
     * @var ScopeRepository $scopeRepository
26
     */
27
    private $scopeRepository;
28
29
    public function __construct(ScopeRepository $scopeRepository, ?string $name = null)
30
    {
31
        $this->scopeRepository = $scopeRepository;
32
        parent::__construct($name);
33
    }
34
35
    /**
36
     * configure options
37
     */
38
    protected function configure()
39
    {
40
        $this->setName('scope:create');
41
        $this->setDescription('Creates a new scope.');
42
        $this->setHelp('Create a new OAuth2 client application');
43
    }
44
45
    /**
46
     * @param InputInterface $input
47
     * @param OutputInterface $output
48
     * @throws \Doctrine\ORM\OptimisticLockException
49
     */
50
    protected function execute(InputInterface $input, OutputInterface $output)
51
    {
52
        $output->writeln('Bone API scope creator');
53
        $helper = $this->getHelper('question');
54
55
        $question = new Question('Name of new scope: ', false);
56
        $scopeName = $helper->ask($input, $output, $question);
57
58
        $question = new Question('Describe this scope: ', false);
59
        $description = $helper->ask($input, $output, $question);
0 ignored issues
show
Unused Code introduced by
The assignment to $description is dead and can be removed.
Loading history...
60
61
        $scope = new Scope();
62
        $scope->setIdentifier($scopeName);
63
64
        $this->scopeRepository->create($scope);
65
66
        $output->writeln('Client created.');
67
    }
68
}