Passed
Push — master ( 07b1ff...049a2e )
by
unknown
07:17 queued 03:58
created

ListCommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 60%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
c 1
b 0
f 1
lcom 0
cbo 2
dl 0
loc 17
ccs 6
cts 10
cp 0.6
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 8 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
            ->setAliases(array('list'))
16 1
            ->setDescription('Lists available commands')
17
        ;
18 1
    }
19
20
    protected function execute(Input\InputInterface $input, OutputInterface $output)
21
    {
22
        $descriptor = new Descriptor\TextDescriptor();
23
        $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...
24
    }
25
}
26