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 (#58)
by joseph
18:31
created

SetEmbeddableCommand   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 83
Duplicated Lines 0 %

Test Coverage

Coverage 75.61%

Importance

Changes 0
Metric Value
wmc 5
dl 0
loc 83
rs 10
c 0
b 0
f 0
ccs 31
cts 41
cp 0.7561

3 Methods

Rating   Name   Duplication   Size   Complexity  
B configure() 0 27 2
A __construct() 0 7 1
A execute() 0 21 2
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\CodeGeneration\NamespaceHelper;
7
use EdmondsCommerce\DoctrineStaticMeta\Exception\DoctrineStaticMetaException;
8
use Symfony\Component\Console\Input\InputInterface;
9
use Symfony\Component\Console\Input\InputOption;
10
use Symfony\Component\Console\Output\OutputInterface;
11
12
class SetEmbeddableCommand extends AbstractCommand
13
{
14
    public const OPT_ENTITY       = 'entity';
15
    public const OPT_ENTITY_SHORT = 'o';
16
17
    public const OPT_EMBEDDABLE       = 'embeddable';
18
    public const OPT_EMBEDDABLE_SHORT = 'b';
19
    /**
20
     * @var EntityEmbeddableSetter
21
     */
22
    protected $embeddableSetter;
23
24 2
    public function __construct(
25
        EntityEmbeddableSetter $embeddableSetter,
26
        NamespaceHelper $namespaceHelper,
27
        ?string $name = null
28
    ) {
29 2
        parent::__construct($namespaceHelper, $name);
30 2
        $this->embeddableSetter = $embeddableSetter;
31 2
    }
32
33
    /**
34
     * @throws DoctrineStaticMetaException
35
     */
36 2
    public function configure(): void
37
    {
38
        try {
39 2
            $this->setName(AbstractCommand::COMMAND_PREFIX.'set:embeddable')
40 2
                 ->setDefinition(
41
                     [
42 2
                         new InputOption(
43 2
                             self::OPT_ENTITY,
44 2
                             self::OPT_ENTITY_SHORT,
45 2
                             InputOption::VALUE_REQUIRED,
46 2
                             'Entity Fully Qualified Name'
47
                         ),
48 2
                         new InputOption(
49 2
                             self::OPT_EMBEDDABLE,
50 2
                             self::OPT_EMBEDDABLE_SHORT,
51 2
                             InputOption::VALUE_REQUIRED,
52 2
                             'Embeddable Trait Fully Qualified Name'
53
                         ),
54
                     ]
55 2
                 )->setDescription(
56 2
                     '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 2
    }
66
67
    /**
68
     * @param InputInterface  $input
69
     * @param OutputInterface $output
70
     *
71
     * @return int|null|void
72
     * @throws DoctrineStaticMetaException
73
     */
74 1
    public function execute(InputInterface $input, OutputInterface $output)
75
    {
76
        try {
77 1
            $output->writeln(
78
                '<comment>Setting Entity '
79 1
                .$input->getOption(static::OPT_ENTITY)
80 1
                .' has Embeddable '.$input->getOption(static::OPT_EMBEDDABLE)
81 1
                .'</comment>'
82
            );
83 1
            $this->checkOptions($input);
84 1
            $this->embeddableSetter
85 1
                ->setEntityHasEmbeddable(
86 1
                    $input->getOption(static::OPT_ENTITY),
87 1
                    $input->getOption(static::OPT_EMBEDDABLE)
88
                );
89 1
            $output->writeln('<info>completed</info>');
90
        } catch (\Exception $e) {
91
            throw new DoctrineStaticMetaException(
92
                'Exception in '.__METHOD__.': '.$e->getMessage(),
93
                $e->getCode(),
94
                $e
95
            );
96
        }
97 1
    }
98
}
99