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 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 2
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
use Deployee\Plugins\Deploy\Definitions\Tasks\TaskDefinitionInterface;
6
use Deployee\Plugins\Deploy\Dispatcher\DispatchResultInterface;
7
use Deployee\Plugins\ShopwareTasks\Definitions\PluginConfigSetDefinition;
8
use Deployee\Plugins\ShopwareTasks\Definitions\ShopwareCommandDefinition;
9
10
class PluginConfigSetDispatcher extends AbstractShopwareDispatcher
11
{
12
    /**
13
     * @param TaskDefinitionInterface $taskDefinition
14
     * @return bool
15
     */
16
    public function canDispatchTaskDefinition(TaskDefinitionInterface $taskDefinition): bool
17
    {
18
        return $taskDefinition instanceof PluginConfigSetDefinition;
19
    }
20
21
    /**
22
     * @param TaskDefinitionInterface $taskDefinition
23
     * @return DispatchResultInterface
24
     * @throws \Deployee\Plugins\Deploy\Exception\DispatcherException
25
     */
26
    public function dispatch(TaskDefinitionInterface $taskDefinition): DispatchResultInterface
27
    {
28
        $params = $taskDefinition->define();
29
        return $this->delegate(new ShopwareCommandDefinition(
30
            'system:config:set',
31
            sprintf(
32
                '-n %s %s %s',
33
                escapeshellarg($params->get('key')),
34
                escapeshellarg($params->get('value')),
35
                $this->getEnvironmentConsoleParameter($taskDefinition)
36
            )
37
        ));
38
    }
39
}