CliController   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 92.31%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 4
dl 0
loc 35
ccs 12
cts 13
cp 0.9231
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A setOutput() 0 4 1
A cliAction() 0 11 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace DoctrineModule\Controller;
6
7
use DoctrineModule\Component\Console\Input\RequestInput;
8
use Laminas\Mvc\Console\View\ViewModel;
9
use Laminas\Mvc\Controller\AbstractActionController;
10
use Symfony\Component\Console\Application;
11
use Symfony\Component\Console\Output\OutputInterface;
12
use function is_numeric;
13
14
/**
15
 * Index controller
16
 */
17
class CliController extends AbstractActionController
18
{
19
    /** @var Application */
20
    protected $cliApplication;
21
22
    /** @var OutputInterface */
23
    protected $output;
24
25 3
    public function __construct(Application $cliApplication)
26
    {
27 3
        $this->cliApplication = $cliApplication;
28 3
    }
29
30 3
    public function setOutput(OutputInterface $output) : void
31
    {
32 3
        $this->output = $output;
33 3
    }
34
35
    /**
36
     * Index action - runs the console application
37
     *
38
     * @return mixed
39
     */
40 2
    public function cliAction()
41
    {
42 2
        $exitCode = $this->cliApplication->run(new RequestInput($this->getRequest()), $this->output);
0 ignored issues
show
Compatibility introduced by
$this->getRequest() of type object<Laminas\Stdlib\RequestInterface> is not a sub-type of object<Laminas\Console\Request>. It seems like you assume a concrete implementation of the interface Laminas\Stdlib\RequestInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
43
44 2
        if (is_numeric($exitCode)) {
45 2
            $model = new ViewModel();
46 2
            $model->setErrorLevel($exitCode);
47
48 2
            return $model;
49
        }
50
    }
51
}
52