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
Pull Request — master (#199)
by joseph
21:04
created

SetEmbeddableCommand::execute()   A

Complexity

Conditions 2
Paths 5

Size

Total Lines 23
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 19
nc 5
nop 2
dl 0
loc 23
ccs 0
cts 23
cp 0
crap 6
rs 9.6333
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\Generator\Embeddable\EntityEmbeddableSetter;
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 SetEmbeddableCommand extends AbstractCommand
12
{
13
    public const OPT_ENTITY       = 'entity';
14
    public const OPT_ENTITY_SHORT = 'o';
15
16
    public const OPT_EMBEDDABLE       = 'embeddable';
17
    public const OPT_EMBEDDABLE_SHORT = 'b';
18
    /**
19
     * @var EntityEmbeddableSetter
20
     */
21
    protected $embeddableSetter;
22
23
    public function __construct(
24
        EntityEmbeddableSetter $embeddableSetter,
25
        ?string $name = null
26
    ) {
27
        parent::__construct($name);
28
        $this->embeddableSetter = $embeddableSetter;
29
    }
30
31
    /**
32
     * @throws DoctrineStaticMetaException
33
     */
34
    public function configure(): void
35
    {
36
        try {
37
            $this->setName(AbstractCommand::COMMAND_PREFIX . 'set:embeddable')
38
                 ->setDefinition(
39
                     [
40
                         new InputOption(
41
                             self::OPT_ENTITY,
42
                             self::OPT_ENTITY_SHORT,
43
                             InputOption::VALUE_REQUIRED,
44
                             'Entity Fully Qualified Name'
45
                         ),
46
                         new InputOption(
47
                             self::OPT_EMBEDDABLE,
48
                             self::OPT_EMBEDDABLE_SHORT,
49
                             InputOption::VALUE_REQUIRED,
50
                             'Embeddable Trait Fully Qualified Name'
51
                         ),
52
                         $this->getProjectRootPathOption(),
53
                         $this->getProjectRootNamespaceOption(),
54
                     ]
55
                 )->setDescription(
56
                     'Set an Entity as having an Embeddable by way of using the Embeddable Trait'
57
                 );
58
        } catch (\Exception $e) {
59
            throw new DoctrineStaticMetaException(
60
                'Exception in ' . __METHOD__ . ': ' . $e->getMessage(),
61
                $e->getCode(),
62
                $e
63
            );
64
        }
65
    }
66
67
    /**
68
     * @param InputInterface  $input
69
     * @param OutputInterface $output
70
     *
71
     * @return int|null|void
72
     * @throws DoctrineStaticMetaException
73
     */
74
    public function execute(InputInterface $input, OutputInterface $output)
75
    {
76
        try {
77
            $output->writeln(
78
                '<comment>Setting Entity '
79
                . $input->getOption(static::OPT_ENTITY)
80
                . ' has Embeddable ' . $input->getOption(static::OPT_EMBEDDABLE)
81
                . '</comment>'
82
            );
83
            $this->checkOptions($input);
84
            $this->embeddableSetter
85
                ->setPathToProjectRoot($input->getOption(self::OPT_PROJECT_ROOT_PATH))
86
                ->setProjectRootNamespace($input->getOption(self::OPT_PROJECT_ROOT_NAMESPACE))
87
                ->setEntityHasEmbeddable(
88
                    $input->getOption(static::OPT_ENTITY),
89
                    $input->getOption(static::OPT_EMBEDDABLE)
90
                );
91
            $output->writeln('<info>completed</info>');
92
        } catch (\Exception $e) {
93
            throw new DoctrineStaticMetaException(
94
                'Exception in ' . __METHOD__ . ': ' . $e->getMessage(),
95
                $e->getCode(),
96
                $e
97
            );
98
        }
99
    }
100
}
101