DockerClientDependencyProvider::getCommandList()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 15
ccs 0
cts 15
cp 0
rs 9.8333
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
declare(strict_types=1);
3
4
namespace Nexus\DockerClient;
5
6
use Nexus\DockerClient\Communication\Command\Build\DockerBuildCommand;
7
use Nexus\DockerClient\Communication\Command\Compose\DockerComposePullCommand;
8
use Nexus\DockerClient\Communication\Command\Compose\DockerComposeRmCommand;
9
use Nexus\DockerClient\Communication\Command\Compose\DockerComposeStopCommand;
10
use Nexus\DockerClient\Communication\Command\Compose\DockerComposeUpCommand;
11
use Nexus\DockerClient\Communication\Command\Container\StartContainerCommand;
12
use Nexus\DockerClient\Communication\Command\Container\StopContainerCommand;
13
use Nexus\DockerClient\Communication\Command\Copy\DockerCpCommand;
14
use Nexus\DockerClient\Communication\Command\Exec\DockerExecCommand;
15
use Nexus\DockerClient\Communication\Command\Restart\DockerRestartCommand;
16
use Nexus\DockerClient\Communication\Command\Volume\VolumeCreateCommand;
17
use Nexus\DockerClient\Communication\Command\Volume\VolumeRemoveCommand;
18
use Xervice\Core\Business\Model\Dependency\DependencyContainerInterface;
19
use Xervice\Core\Business\Model\Dependency\Provider\AbstractDependencyProvider;
20
21
class DockerClientDependencyProvider extends AbstractDependencyProvider
22
{
23
    public const SHELL_FACADE = 'shell.facade';
24
    public const COMMAND_LIST = 'command.list';
25
26
    /**
27
     * @param \Xervice\Core\Business\Model\Dependency\DependencyContainerInterface $container
28
     *
29
     * @return \Xervice\Core\Business\Model\Dependency\DependencyContainerInterface
30
     */
31
    public function handleDependencies(DependencyContainerInterface $container): DependencyContainerInterface
32
    {
33
        $container = $this->addShellFacade($container);
34
        $container = $this->addCommandList($container);
35
36
        return $container;
37
    }
38
39
    /**
40
     * @return array
41
     * @throws \Symfony\Component\Console\Exception\LogicException
42
     */
43
    protected function getCommandList(): array
44
    {
45
        return [
46
            new DockerComposeUpCommand(),
47
            new DockerComposeRmCommand(),
48
            new DockerComposePullCommand(),
49
            new DockerComposeStopCommand(),
50
            new VolumeCreateCommand(),
51
            new VolumeRemoveCommand(),
52
            new DockerExecCommand(),
53
            new StartContainerCommand(),
54
            new StopContainerCommand(),
55
            new DockerCpCommand(),
56
            new DockerBuildCommand(),
57
            new DockerRestartCommand()
58
        ];
59
    }
60
61
    /**
62
     * @param \Xervice\Core\Business\Model\Dependency\DependencyContainerInterface $container
63
     *
64
     * @return \Xervice\Core\Business\Model\Dependency\DependencyContainerInterface
65
     */
66
    private function addShellFacade(DependencyContainerInterface $container): DependencyContainerInterface
67
    {
68
        $container[self::SHELL_FACADE] = function (DependencyContainerInterface $container) {
69
            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

69
            return $container->getLocator()->shell()->/** @scrutinizer ignore-call */ facade();
Loading history...
70
        };
71
72
        return $container;
73
    }
74
75
    /**
76
     * @param \Xervice\Core\Business\Model\Dependency\DependencyContainerInterface $container
77
     *
78
     * @return \Xervice\Core\Business\Model\Dependency\DependencyContainerInterface
79
     */
80
    protected function addCommandList(
81
        DependencyContainerInterface $container
82
    ): DependencyContainerInterface {
83
        $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

83
        $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...
84
            return $this->getCommandList();
85
        };
86
87
        return $container;
88
    }
89
}