ClientCreateCommand::configure()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 8
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace App\Authorization\Console;
4
5
use FOS\OAuthServerBundle\Entity\ClientManager;
6
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Input\InputOption;
9
use Symfony\Component\Console\Output\OutputInterface;
10
class ClientCreateCommand extends ContainerAwareCommand
0 ignored issues
show
Deprecated Code introduced by
The class Symfony\Bundle\Framework...d\ContainerAwareCommand has been deprecated: since Symfony 4.2, use {@see Command} instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

10
class ClientCreateCommand extends /** @scrutinizer ignore-deprecated */ ContainerAwareCommand
Loading history...
11
12
{
13
14
    /**
15
     * @var ClientManager
16
     */
17
    private $clientManager;
18
19
    protected function configure()
20
    {
21
22
        $this
23
            ->setName('oauth:client:create')
24
            ->setDescription('Creates a new client')
25
            ->addOption('redirect-uri', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_OPTIONAL, 'Sets the redirect uri. Use multiple times to set multiple uris.', [])
26
            ->addOption('grant-type', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_OPTIONAL, 'Set allowed grant type. Use multiple times to set multiple grant types', 'client_credentials')
27
        ;
28
    }
29
    protected function execute(InputInterface $input, OutputInterface $output)
30
    {
31
32
        $this->clientManager = $this->getContainer()->get('fos_oauth_server.client_manager.default'); ;
33
        $client = $this->clientManager->createClient();
0 ignored issues
show
Bug introduced by
The method createClient() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

33
        /** @scrutinizer ignore-call */ 
34
        $client = $this->clientManager->createClient();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
34
        $client->setRedirectUris($input->getOption('redirect-uri'));
35
        $client->setAllowedGrantTypes([$input->getOption('grant-type')]);
36
        $this->clientManager->updateClient($client);
37
        $output->writeln(sprintf('Added a new client with  public id <info>%s</info>.', $client->getPublicId()));
38
    }
39
}