Test Failed
Push — master ( fdad3b...1a9d53 )
by Mike
07:27
created

CustomCommandDependencyProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 83.33%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 22
ccs 5
cts 6
cp 0.8333
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handleDependencies() 0 4 1
A addShellFacade() 0 6 1
1
<?php
2
3
4
namespace Nexus\CustomCommand;
5
6
7
use Xervice\Core\Dependency\DependencyProviderInterface;
8
use Xervice\Core\Dependency\Provider\AbstractProvider;
9
10
/**
11
 * @method \Xervice\Core\Locator\Locator getLocator()
12
 */
13
class CustomCommandDependencyProvider extends AbstractProvider
14
{
15
    const SHELL_FACADE = 'shell.facade';
16
17
    /**
18
     * @param \Xervice\Core\Dependency\DependencyProviderInterface $container
19
     */
20 1
    public function handleDependencies(DependencyProviderInterface $container)
21
    {
22 1
        $this->addShellFacade($container);
0 ignored issues
show
Unused Code introduced by
The call to the method Nexus\CustomCommand\Cust...vider::addShellFacade() seems un-needed as the method has no side-effects.

PHP Analyzer performs a side-effects analysis of your code. A side-effect is basically anything that might be visible after the scope of the method is left.

Let’s take a look at an example:

class User
{
    private $email;

    public function getEmail()
    {
        return $this->email;
    }

    public function setEmail($email)
    {
        $this->email = $email;
    }
}

If we look at the getEmail() method, we can see that it has no side-effect. Whether you call this method or not, no future calls to other methods are affected by this. As such code as the following is useless:

$user = new User();
$user->getEmail(); // This line could safely be removed as it has no effect.

On the hand, if we look at the setEmail(), this method _has_ side-effects. In the following case, we could not remove the method call:

$user = new User();
$user->setEmail('email@domain'); // This line has a side-effect (it changes an
                                 // instance variable).
Loading history...
23 1
    }
24
25
    /**
26
     * @param \Xervice\Core\Dependency\DependencyProviderInterface $container
27
     */
28 1
    private function addShellFacade(DependencyProviderInterface $container): void
29
    {
30
        $container[self::SHELL_FACADE] = function(DependencyProviderInterface $container) {
31
            return $container->getLocator()->shell()->facade();
32
        };
33
    }
34
}