Completed
Push — master ( 579af5...b29473 )
by Oleg
07:53
created

ConsoleResolver   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 29
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getApplication() 0 4 1
A getAction() 0 7 1
1
<?php /** MicroConsoleResolver */
2
3
namespace Micro\Resolver;
4
5
use Micro\Cli\Console;
6
7
/**
8
 * CLI Resolver class file.
9
 *
10
 * @author Oleg Lunegov <[email protected]>
11
 * @link https://github.com/lugnsk/micro
12
 * @copyright Copyright &copy; 2013 Oleg Lunegov
13
 * @license /LICENSE
14
 * @package Micro
15
 * @subpackage Resolver
16
 * @version 1.0
17
 * @since 1.0
18
 */
19
class ConsoleResolver extends Resolver
20
{
21
    /**
22
     * Get instance application
23
     *
24
     * @access public
25
     *
26
     * @return \Micro\Base\Command
27
     */
28
    public function getApplication()
29
    {
30
        return new Console($this->container);
31
    }
32
33
    /**
34
     * Get action from request
35
     *
36
     * @access public
37
     *
38
     * @return string
39
     */
40
    public function getAction()
41
    {
42
        $params = $this->container->request->getArguments();
0 ignored issues
show
Bug introduced by
Accessing request on the interface Micro\Base\IContainer suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
43
        array_shift($params);
44
45
        return ucfirst(array_shift($params));
46
    }
47
}
48