canDispatchTaskDefinition()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
1
<?php
2
3
namespace Deployee\Plugins\ShopwareTasks\Dispatcher;
4
5
6
use Deployee\Plugins\Deploy\Definitions\Tasks\TaskDefinitionInterface;
7
use Deployee\Plugins\Deploy\Dispatcher\AbstractTaskDefinitionDispatcher;
8
use Deployee\Plugins\Deploy\Dispatcher\DispatchResultInterface;
9
use Deployee\Plugins\ShopwareTasks\Definitions\PluginDeactivateDefinition;
10
use Deployee\Plugins\ShopwareTasks\Definitions\ShopwareCommandDefinition;
11
12
class PluginDeactivateDispatcher extends AbstractTaskDefinitionDispatcher
13
{
14
    /**
15
     * @param TaskDefinitionInterface $taskDefinition
16
     * @return bool
17
     */
18
    public function canDispatchTaskDefinition(TaskDefinitionInterface $taskDefinition): bool
19
    {
20
        return $taskDefinition instanceof PluginDeactivateDefinition;
21
    }
22
23
    /**
24
     * @param TaskDefinitionInterface $taskDefinition
25
     * @return DispatchResultInterface
26
     * @throws \Deployee\Plugins\Deploy\Exception\DispatcherException
27
     */
28
    public function dispatch(TaskDefinitionInterface $taskDefinition): DispatchResultInterface
29
    {
30
        $parameter = $taskDefinition->define();
31
32
        return $this->delegate(
33
            new ShopwareCommandDefinition('plugin:deactivate', '-n ' . $parameter->get('plugin'))
34
        );
35
    }
36
}