Passed
Push — master ( 35eebd...7b8a1a )
by Roman
16:45
created

AbstractCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 71.43%

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 28
ccs 10
cts 14
cp 0.7143
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A validateInput() 0 2 1
A execute() 0 19 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Game\Features\Registration\Console;
6
7
use Symfony\Component\Console\Command\Command;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Console\Command\Command was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use Symfony\Component\Console\Input\InputInterface;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Console\Input\InputInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use Symfony\Component\Console\Output\OutputInterface;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Console\Output\OutputInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
use Symfony\Component\Console\Style\SymfonyStyle;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Console\Style\SymfonyStyle was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use Throwable;
12
13
abstract class AbstractCommand extends Command
14
{
15
    abstract protected function doExecute(InputInterface $input): string;
16
17 3
    protected function execute(InputInterface $input, OutputInterface $output): int
18
    {
19 3
        $this->validateInput($input);
20 3
        $symfonyStyle = new SymfonyStyle($input, $output);
21
        try {
22 3
            $memory = memory_get_usage();
23 3
            $start = microtime(true);
24 3
            $symfonyStyle->info($this->doExecute($input));
25 3
            $stop = number_format(microtime(true) - $start, 2);
26
27 3
            $symfonyStyle->success(
28 3
                sprintf('Process took %f seconds. Memory used %f bytes.', $stop, memory_get_usage() - $memory)
29
            );
30
31 3
            return Command::SUCCESS;
32
        } catch (Throwable $exception) {
33
            $symfonyStyle->error($exception->getMessage());
34
35
            return Command::FAILURE;
36
        }
37
    }
38
39
    protected function validateInput(InputInterface $input): void
40
    {
41
    }
42
}
43