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 (#154)
by joseph
33:02
created

RemoveUnusedRelationsCommand   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Test Coverage

Coverage 71.43%

Importance

Changes 0
Metric Value
eloc 34
dl 0
loc 66
ccs 25
cts 35
cp 0.7143
rs 10
c 0
b 0
f 0
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A configure() 0 20 2
A execute() 0 19 2
1
<?php declare(strict_types=1);
2
3
namespace EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Command;
4
5
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\UnusedRelationsRemover;
6
use EdmondsCommerce\DoctrineStaticMeta\Exception\DoctrineStaticMetaException;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Output\OutputInterface;
9
10
class RemoveUnusedRelationsCommand extends AbstractCommand
11
{
12
    /**
13
     * @var UnusedRelationsRemover
14
     */
15
    protected $remover;
16
17 2
    public function __construct(UnusedRelationsRemover $remover, ?string $name = null)
18
    {
19 2
        parent::__construct($name);
20 2
        $this->remover = $remover;
21 2
    }
22
23
    /**
24
     * @throws DoctrineStaticMetaException
25
     */
26 2
    public function configure(): void
27
    {
28
        try {
29 2
            $this->setName(AbstractCommand::COMMAND_PREFIX . 'finalise:remove-unused-relations')
30 2
                 ->setAliases([
31 2
                                  AbstractCommand::COMMAND_PREFIX . 'remove:unusedRelations',
32
                              ])
33 2
                 ->setDefinition(
34
                     [
35 2
                         $this->getProjectRootPathOption(),
36 2
                         $this->getProjectRootNamespaceOption(),
37
                     ]
38 2
                 )->setDescription(
39 2
                     'Find and remove unused relations traits and interfaces'
40
                 );
41
        } catch (\Exception $e) {
42
            throw new DoctrineStaticMetaException(
43
                'Exception in ' . __METHOD__ . ': ' . $e->getMessage(),
44
                $e->getCode(),
45
                $e
46
            );
47
        }
48 2
    }
49
50
    /**
51
     * @param InputInterface  $input
52
     * @param OutputInterface $output
53
     *
54
     * @return int|null|void
55
     * @throws DoctrineStaticMetaException
56
     */
57 2
    public function execute(InputInterface $input, OutputInterface $output)
58
    {
59
        try {
60 2
            $output->writeln(
61 2
                '<comment>Finding and Removing Unused Generated Code</comment>'
62
            );
63 2
            $this->checkOptions($input);
64 2
            $removedFiles = $this->remover
65 2
                ->setPathToProjectRoot($input->getOption(self::OPT_PROJECT_ROOT_PATH))
66 2
                ->setProjectRootNamespace($input->getOption(self::OPT_PROJECT_ROOT_NAMESPACE))
67 2
                ->run();
68 2
            $output->writeln('<comment>Removed ' . count($removedFiles) . ' Files:</comment>');
69 2
            $output->writeln(print_r($removedFiles, true));
70 2
            $output->writeln('<info>completed</info>');
71
        } catch (\Exception $e) {
72
            throw new DoctrineStaticMetaException(
73
                'Exception in ' . __METHOD__ . ': ' . $e->getMessage(),
74
                $e->getCode(),
75
                $e
76
            );
77
        }
78 2
    }
79
}
80