ScopeListCommand::execute()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
cc 3
eloc 6
nc 4
nop 2
dl 0
loc 10
ccs 0
cts 7
cp 0
crap 12
rs 10
c 0
b 0
f 0
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 ScopeListCommand
20
 * @package OAuth\Command
21
 */
22
class ScopeListCommand 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:list');
41
        $this->setDescription('Lists all scopes.');
42
        $this->setHelp('Lists available access scopes.');
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('Listing scopes...');
53
        $scopes = $this->scopeRepository->findAll();
54
        if (!count($scopes)) {
55
            $output->writeln('No scopes found.');
56
        }
57
        /** @var Scope $scope */
58
        foreach ($scopes as $scope) {
59
            $output->writeln(' - ' . $scope->getIdentifier());
60
        }
61
    }
62
}