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.
Passed
Pull Request — master (#58)
by joseph
17:08
created

GenerateEmbeddableFromArchetypeCommand   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 89
Duplicated Lines 0 %

Test Coverage

Coverage 77.78%

Importance

Changes 0
Metric Value
wmc 5
dl 0
loc 89
rs 10
c 0
b 0
f 0
ccs 35
cts 45
cp 0.7778

3 Methods

Rating   Name   Duplication   Size   Complexity  
B configure() 0 30 2
A execute() 0 23 2
A __construct() 0 7 1
1
<?php declare(strict_types=1);
2
3
namespace EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Command;
4
5
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Generator\Embeddable\ArchetypeEmbeddableGenerator;
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 GenerateEmbeddableFromArchetypeCommand extends AbstractCommand
13
{
14
    public const OPT_NEW_EMBEDDABLE_CLASS_NAME       = 'classname';
15
    public const OPT_NEW_EMBEDDABLE_CLASS_NAME_SHORT = 'c';
16
17
    public const OPT_ARCHETYPE_OBJECT_FQN       = 'archetype';
18
    public const OPT_ARCHETYPE_OBJECT_FQN_SHORT = 'a';
19
    /**
20
     * @var ArchetypeEmbeddableGenerator
21
     */
22
    protected $embeddableGenerator;
23
24 2
    public function __construct(
25
        ArchetypeEmbeddableGenerator $embeddableGenerator,
26
        NamespaceHelper $namespaceHelper,
27
        ?string $name = null
28
    ) {
29 2
        parent::__construct($namespaceHelper, $name);
30 2
        $this->embeddableGenerator = $embeddableGenerator;
31 2
    }
32
33
34
    /**
35
     * @throws DoctrineStaticMetaException
36
     */
37 2
    protected function configure(): void
38
    {
39
        try {
40
            $this
41 2
                ->setName(AbstractCommand::COMMAND_PREFIX.'generate:embeddable')
42 2
                ->setDefinition(
43
                    [
44 2
                        new InputOption(
45 2
                            self::OPT_NEW_EMBEDDABLE_CLASS_NAME,
46 2
                            self::OPT_NEW_EMBEDDABLE_CLASS_NAME_SHORT,
47 2
                            InputOption::VALUE_REQUIRED,
48 2
                            'The short class name for the new Embeddable Object'
49
                        ),
50 2
                        new InputOption(
51 2
                            self::OPT_ARCHETYPE_OBJECT_FQN,
52 2
                            self::OPT_ARCHETYPE_OBJECT_FQN_SHORT,
53 2
                            InputOption::VALUE_REQUIRED,
54 2
                            'The fully qualified name for the archetype Embeddable Object'
55
                        ),
56 2
                        $this->getProjectRootPathOption(),
57 2
                        $this->getProjectRootNamespaceOption(),
58
                    ]
59 2
                )->setDescription(
60 2
                    'Generate an Embeddable from an Archetype Embeddable'
61
                );
62
        } catch (\Exception $e) {
63
            throw new DoctrineStaticMetaException(
64
                'Exception in '.__METHOD__.': '.$e->getMessage(),
65
                $e->getCode(),
66
                $e
67
            );
68
        }
69 2
    }
70
71
    /**
72
     * @param InputInterface  $input
73
     * @param OutputInterface $output
74
     *
75
     * @return int|null|void
76
     * @throws DoctrineStaticMetaException
77
     */
78 1
    public function execute(InputInterface $input, OutputInterface $output)
79
    {
80
        try {
81 1
            $output->writeln(
82
                '<comment>Generating new Embeddable  '
83 1
                .$input->getOption(static::OPT_NEW_EMBEDDABLE_CLASS_NAME)
84 1
                .' from archetype '.$input->getOption(static::OPT_ARCHETYPE_OBJECT_FQN)
85 1
                .'</comment>'
86
            );
87 1
            $this->checkOptions($input);
88 1
            $this->embeddableGenerator
89 1
                ->setPathToProjectRoot($input->getOption(AbstractCommand::OPT_PROJECT_ROOT_PATH))
90 1
                ->setProjectRootNamespace($input->getOption(AbstractCommand::OPT_PROJECT_ROOT_NAMESPACE))
91 1
                ->createFromArchetype(
92 1
                    $input->getOption(static::OPT_ARCHETYPE_OBJECT_FQN),
93 1
                    $input->getOption(static::OPT_NEW_EMBEDDABLE_CLASS_NAME)
94
                );
95 1
            $output->writeln('<info>completed</info>');
96
        } catch (\Exception $e) {
97
            throw new DoctrineStaticMetaException(
98
                'Exception in '.__METHOD__.': '.$e->getMessage(),
99
                $e->getCode(),
100
                $e
101
            );
102
        }
103 1
    }
104
}
105