DatabaseList::execute()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 24
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 11
c 1
b 0
f 1
dl 0
loc 24
rs 9.9
cc 2
nc 2
nop 2
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace Db3v4l\Command;
4
5
use Db3v4l\Core\DatabaseSchemaManager;
0 ignored issues
show
Bug introduced by
The type Db3v4l\Core\DatabaseSchemaManager 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...
6
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...
7
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...
8
9
class DatabaseList extends SQLExecutingCommand
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class DatabaseList
Loading history...
10
{
11
    protected static $defaultName = 'db3v4l:database:list';
12
13
    protected function configure()
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function configure()
Loading history...
14
    {
15
        $this
16
            ->setDescription('Lists all existing databases on all configured database instances')
17
            ->addCommonOptions()
0 ignored issues
show
Coding Style introduced by
Space after closing parenthesis of function call prohibited
Loading history...
18
        ;
19
    }
20
21
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
22
     * @param InputInterface $input
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 2 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
23
     * @param OutputInterface $output
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
24
     * @return int
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
25
     * @throws \Exception
0 ignored issues
show
Coding Style introduced by
Tag @throws cannot be grouped with parameter tags in a doc comment
Loading history...
26
     */
27
    protected function execute(InputInterface $input, OutputInterface $output)
28
    {
29
        $start = microtime(true);
30
31
        // as per https://www.php.net/manual/en/function.ignore-user-abort.php: for cli scripts, it is probably a good idea
32
        // to use ignore_user_abort
33
        ignore_user_abort(true);
34
35
        $this->setOutput($output);
36
        $this->setVerbosity($output->getVerbosity());
37
38
        $instanceList = $this->parseCommonOptions($input);
39
40
        if ($this->outputFormat === 'text') {
41
            $this->writeln('<info>Analyzing databases...</info>', OutputInterface::VERBOSITY_VERBOSE);
42
        }
43
44
        $results = $this->listDatabases($instanceList);
45
46
        $time = microtime(true) - $start;
47
48
        $this->writeResults($results, $time);
49
50
        return (int)$results['failed'];
51
    }
52
53
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
54
     * @param string[][] $instanceList
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
55
     * @return array
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
56
     * @throws \Exception
0 ignored issues
show
Coding Style introduced by
Tag @throws cannot be grouped with parameter tags in a doc comment
Loading history...
57
     */
58
    protected function listDatabases($instanceList)
59
    {
60
        return $this->executeSqlAction(
61
            $instanceList,
62
            'Listing of databases',
63
            function ($schemaManager, $instanceName) {
0 ignored issues
show
Unused Code introduced by
The parameter $instanceName is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

63
            function ($schemaManager, /** @scrutinizer ignore-unused */ $instanceName) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
64
                /** @var DatabaseSchemaManager $schemaManager */
0 ignored issues
show
Coding Style introduced by
The open comment tag must be the only content on the line
Loading history...
Coding Style introduced by
Missing short description in doc comment
Loading history...
Coding Style introduced by
The close comment tag must be the only content on the line
Loading history...
65
                return $schemaManager->getListDatabasesSqlAction();
66
            }
67
        );
68
    }
69
}
70