Completed
Pull Request — master (#615)
by Filippo
14:02 queued 03:29
created

CliController   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 92.31%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A setOutput() 0 4 1
A cliAction() 0 11 3
1
<?php
2
/*
3
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14
 *
15
 * This software consists of voluntary contributions made by many individuals
16
 * and is licensed under the MIT license.
17
 */
18
19
namespace DoctrineModule\Controller;
20
21
use Symfony\Component\Console\Application;
22
use Symfony\Component\Console\Output\OutputInterface;
23
use Zend\Mvc\Console\View\ViewModel;
24
use Zend\Mvc\Controller\AbstractActionController;
25
use Zend\View\Model\ConsoleModel as V2ViewModel;
26
use DoctrineModule\Component\Console\Input\RequestInput;
27
28
/**
29
 * Index controller
30
 *
31
 * @license MIT
32
 * @author Aleksandr Sandrovskiy <[email protected]>
33
 */
34
class CliController extends AbstractActionController
35
{
36
    /**
37
     * @var \Symfony\Component\Console\Application
38
     */
39
    protected $cliApplication;
40
41
    /**
42
     * @var \Symfony\Component\Console\Output\OutputInterface
43
     */
44
    protected $output;
45
46
    /**
47
     * @param \Symfony\Component\Console\Application $cliApplication
48
     */
49 3
    public function __construct(Application $cliApplication)
50
    {
51 3
        $this->cliApplication = $cliApplication;
52 3
    }
53
54 3
    public function setOutput(OutputInterface $output)
55
    {
56 3
        $this->output = $output;
57 3
    }
58
59
    /**
60
     * Index action - runs the console application
61
     */
62 2
    public function cliAction()
63
    {
64 2
        $exitCode = $this->cliApplication->run(new RequestInput($this->getRequest()), $this->output);
0 ignored issues
show
Compatibility introduced by
$this->getRequest() of type object<Zend\Stdlib\RequestInterface> is not a sub-type of object<Zend\Console\Request>. It seems like you assume a concrete implementation of the interface Zend\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...
65
66 2
        if (is_numeric($exitCode)) {
67 2
            $model = class_exists(ViewModel::class) ? new ViewModel() : new V2ViewModel();
68 2
            $model->setErrorLevel($exitCode);
69
70 2
            return $model;
71
        }
72
    }
73
}
74