Passed
Push — master ( 62679a...2b0c72 )
by Gerard van
07:11
created

ListCommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 55.56%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
c 1
b 0
f 1
lcom 0
cbo 2
dl 0
loc 16
ccs 5
cts 9
cp 0.5556
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 7 1
A execute() 0 5 1
1
<?php
2
3
namespace Zicht\Tool\Command;
4
5
use Symfony\Component\Console\Output\OutputInterface;
6
use Symfony\Component\Console\Input;
7
use Symfony\Component\Console\Command\Command;
8
9
class ListCommand extends Command
10
{
11 1
    protected function configure()
12
    {
13 1
        $this
14 1
            ->setName('z:list')
15 1
            ->setDescription('Lists available commands')
16
        ;
17 1
    }
18
19
    protected function execute(Input\InputInterface $input, OutputInterface $output)
20
    {
21
        $descriptor = new Descriptor\TextDescriptor();
22
        $descriptor->describe($output, $this->getApplication());
0 ignored issues
show
Bug introduced by
It seems like $this->getApplication() can be null; however, describe() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
23
    }
24
}
25