GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 75bdf9...8faa57 )
by joseph
83:56 queued 81:04
created

CreateConstraintCommand::configure()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 24
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 2.1017

Importance

Changes 0
Metric Value
cc 2
eloc 18
nc 2
nop 0
dl 0
loc 24
ccs 12
cts 17
cp 0.7059
crap 2.1017
rs 9.6666
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Command;
4
5
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Action\CreateConstraintAction;
6
use EdmondsCommerce\DoctrineStaticMeta\Exception\DoctrineStaticMetaException;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Input\InputOption;
9
use Symfony\Component\Console\Output\OutputInterface;
10
11
class CreateConstraintCommand extends AbstractCommand
12
{
13
    public const OPT_CONSTRAINT_SHORT_NAME        = 'constraint-short-name';
14
    public const OPT_CONSTRAINT_SHORT_NAME_SHORT  = 'c';
15
    public const DEFINITION_CONSTRAINT_SHORT_NAME =
16
        'The short basename of the Constraint you want ot create. ' .
17
        'It will then generate both the Constrain and ConstraintValidator objects as required';
18
19
    /**
20
     * @var CreateConstraintAction
21
     */
22
    protected $action;
23
24 1
    public function __construct(CreateConstraintAction $action, ?string $name = null)
25
    {
26 1
        parent::__construct($name);
27 1
        $this->action = $action;
28 1
    }
29
30 1
    public function execute(InputInterface $input, OutputInterface $output)
31
    {
32
        try {
33 1
            $this->checkOptions($input);
34 1
            $output->writeln(
35
                '<comment>Starting generation for '
36 1
                . $input->getOption(self::OPT_CONSTRAINT_SHORT_NAME) . '</comment>'
37
            );
38 1
            $this->action->setProjectRootNamespace($input->getOption(self::OPT_PROJECT_ROOT_NAMESPACE))
39 1
                         ->setProjectRootDirectory($input->getOption(self::OPT_PROJECT_ROOT_PATH))
40 1
                         ->setConstraintShortName($input->getOption(self::OPT_CONSTRAINT_SHORT_NAME))
41 1
                         ->run();
42 1
            $output->writeln('<info>completed</info>');
43
        } catch (\Exception $e) {
44
            throw new DoctrineStaticMetaException(
45
                'Exception in ' . __METHOD__ . ': ' . $e->getMessage(),
46
                $e->getCode(),
47
                $e
48
            );
49
        }
50 1
    }
51
52
    /**
53
     * @throws DoctrineStaticMetaException
54
     */
55 1
    protected function configure(): void
56
    {
57
        try {
58
            $this
59 1
                ->setName(AbstractCommand::COMMAND_PREFIX . 'generate:constraint')
60 1
                ->setDefinition(
61
                    [
62 1
                        new InputOption(
63 1
                            self::OPT_CONSTRAINT_SHORT_NAME,
64 1
                            self::OPT_CONSTRAINT_SHORT_NAME_SHORT,
65 1
                            InputOption::VALUE_REQUIRED,
66 1
                            self::DEFINITION_CONSTRAINT_SHORT_NAME
67
                        ),
68 1
                        $this->getProjectRootPathOption(),
69 1
                        $this->getProjectRootNamespaceOption(),
70
                    ]
71 1
                )->setDescription(
72 1
                    'Generate a a custom constraint'
73
                );
74
        } catch (\Exception $e) {
75
            throw new DoctrineStaticMetaException(
76
                'Exception in ' . __METHOD__ . ': ' . $e->getMessage(),
77
                $e->getCode(),
78
                $e
79
            );
80
        }
81 1
    }
82
}
83