DumperDependencyProvider   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
eloc 22
dl 0
loc 73
ccs 0
cts 34
cp 0
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A addShellFacade() 0 7 1
A getCommandList() 0 7 1
A addCommandList() 0 7 1
A addDockerFacade() 0 7 1
A handleDependencies() 0 7 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Nexus\Dumper;
5
6
use Nexus\Dumper\Communication\Command\DumpLocalCommand;
7
use Nexus\Dumper\Communication\Command\DumpSshCommand;
8
use Nexus\Dumper\Communication\Command\RestoreLocalCommand;
9
use Nexus\Dumper\Communication\Command\RestoreSshCommand;
10
use Xervice\Core\Business\Model\Dependency\DependencyContainerInterface;
11
use Xervice\Core\Business\Model\Dependency\Provider\AbstractDependencyProvider;
12
13
class DumperDependencyProvider extends AbstractDependencyProvider
14
{
15
    public const DOCKER_FACADE = 'docker.facade';
16
    public const SHELL_FACADE = 'shell.facade';
17
    public const COMMAND_LIST = 'command.list';
18
19
    /**
20
     * @param \Xervice\Core\Business\Model\Dependency\DependencyContainerInterface $container
21
     *
22
     * @return \Xervice\Core\Business\Model\Dependency\DependencyContainerInterface
23
     */
24
    public function handleDependencies(DependencyContainerInterface $container): DependencyContainerInterface
25
    {
26
        $container = $this->addShellFacade($container);
27
        $container = $this->addDockerFacade($container);
28
        $container = $this->addCommandList($container);
29
30
        return $container;
31
    }
32
33
    /**
34
     * @return array
35
     */
36
    protected function getCommandList(): array
37
    {
38
        return [
39
            new DumpLocalCommand(),
40
            new DumpSshCommand(),
41
            new RestoreLocalCommand(),
42
            new RestoreSshCommand()
43
        ];
44
    }
45
46
    /**
47
     * @param \Xervice\Core\Business\Model\Dependency\DependencyContainerInterface $container
48
     *
49
     * @return \Xervice\Core\Business\Model\Dependency\DependencyContainerInterface
50
     */
51
    private function addShellFacade(DependencyContainerInterface $container): DependencyContainerInterface
52
    {
53
        $container[self::SHELL_FACADE] = function(DependencyContainerInterface $container) {
54
            return $container->getLocator()->shell()->facade();
0 ignored issues
show
Bug introduced by
The method facade() does not exist on Xervice\Core\Business\Mo...y\LocatorProxyInterface. It seems like you code against a sub-type of said class. However, the method does not exist in Xervice\Core\Business\Mo...xy\AbstractLocatorProxy or Xervice\Core\Business\Mo...PersistenceLocatorProxy. Are you sure you never get one of those? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

54
            return $container->getLocator()->shell()->/** @scrutinizer ignore-call */ facade();
Loading history...
55
        };
56
57
        return $container;
58
    }
59
60
    /**
61
     * @param \Xervice\Core\Business\Model\Dependency\DependencyContainerInterface $container
62
     *
63
     * @return \Xervice\Core\Business\Model\Dependency\DependencyContainerInterface
64
     */
65
    private function addDockerFacade(DependencyContainerInterface $container): DependencyContainerInterface
66
    {
67
        $container[self::DOCKER_FACADE] = function(DependencyContainerInterface $container) {
68
            return $container->getLocator()->dockerClient()->facade();
69
        };
70
71
        return $container;
72
    }
73
74
    /**
75
     * @param \Xervice\Core\Business\Model\Dependency\DependencyContainerInterface $container
76
     *
77
     * @return \Xervice\Core\Business\Model\Dependency\DependencyContainerInterface
78
     */
79
    protected function addCommandList(
80
        DependencyContainerInterface $container
81
    ): DependencyContainerInterface {
82
        $container[self::COMMAND_LIST] = function (DependencyContainerInterface $container) {
0 ignored issues
show
Unused Code introduced by
The parameter $container is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

82
        $container[self::COMMAND_LIST] = function (/** @scrutinizer ignore-unused */ DependencyContainerInterface $container) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
83
            return $this->getCommandList();
84
        };
85
        return $container;
86
}
87
}