Completed
Push — master ( 073016...e095ce )
by Derek Stephen
04:16
created

ScopeListCommand   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 38
ccs 0
cts 16
cp 0
rs 10
c 0
b 0
f 0
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 10 3
A __construct() 0 4 1
A configure() 0 5 1
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
}