PluginUninstallDispatcher::dispatch()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 8
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 10
ccs 0
cts 3
cp 0
crap 6
rs 10
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\PluginUninstallDefinition;
9
use Deployee\Plugins\ShopwareTasks\Definitions\ShopwareCommandDefinition;
10
11
class PluginUninstallDispatcher extends AbstractTaskDefinitionDispatcher
12
{
13
    /**
14
     * @param TaskDefinitionInterface $taskDefinition
15
     * @return bool
16
     */
17
    public function canDispatchTaskDefinition(TaskDefinitionInterface $taskDefinition): bool
18
    {
19
        return $taskDefinition instanceof PluginUninstallDefinition;
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:uninstall',
33
                sprintf(
34
                    '-n %s %s',
35
                    $parameter->get('secure') === true ? '--secure' : '',
36
                    $parameter->get('plugin')
37
                )
38
            )
39
        );
40
    }
41
}