PluginInstallDispatcher   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 26
ccs 0
cts 5
cp 0
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A dispatch() 0 10 2
A canDispatchTaskDefinition() 0 3 1
1
<?php
2
3
namespace Deployee\Plugins\ShopwareTasks\Dispatcher;
4
5
use Deployee\Plugins\Deploy\Definitions\Tasks\TaskDefinitionInterface;
6
use Deployee\Plugins\Deploy\Dispatcher\AbstractTaskDefinitionDispatcher;
7
use Deployee\Plugins\Deploy\Dispatcher\DispatchResultInterface;
8
use Deployee\Plugins\ShopwareTasks\Definitions\PluginInstallDefinition;
9
use Deployee\Plugins\ShopwareTasks\Definitions\ShopwareCommandDefinition;
10
11
class PluginInstallDispatcher extends AbstractTaskDefinitionDispatcher
12
{
13
    /**
14
     * @param TaskDefinitionInterface $taskDefinition
15
     * @return bool
16
     */
17
    public function canDispatchTaskDefinition(TaskDefinitionInterface $taskDefinition): bool
18
    {
19
        return $taskDefinition instanceof PluginInstallDefinition;
20
    }
21
22
    /**
23
     * @param TaskDefinitionInterface $taskDefinition
24
     * @return DispatchResultInterface
25
     * @throws \Deployee\Plugins\Deploy\Exception\DispatcherException
26
     */
27
    public function dispatch(TaskDefinitionInterface $taskDefinition): DispatchResultInterface
28
    {
29
        $parameter = $taskDefinition->define();
30
        return $this->delegate(
31
            new ShopwareCommandDefinition(
32
                'plugin:install',
33
                sprintf(
34
                    '-n %s %s',
35
                    $parameter->get('activate') === true ? '--activate' : '',
36
                    $parameter->get('plugin')
37
                )
38
            )
39
        );
40
    }
41
}