GenerateThemeCacheDispatcher   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A canDispatchTaskDefinition() 0 3 1
A dispatch() 0 12 2
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\GenerateThemeCacheDefinition;
9
use Deployee\Plugins\ShopwareTasks\Definitions\ShopwareCommandDefinition;
10
11
class GenerateThemeCacheDispatcher extends AbstractTaskDefinitionDispatcher
12
{
13
    /**
14
     * @param TaskDefinitionInterface $taskDefinition
15
     * @return bool
16
     */
17
    public function canDispatchTaskDefinition(TaskDefinitionInterface $taskDefinition): bool
18
    {
19
        return $taskDefinition instanceof GenerateThemeCacheDefinition;
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
        $shopIds = $parameter->get('shopId');
31
32
        $arguments = '';
33
        foreach($shopIds as $shopId){
34
            $arguments .= ' --shopId=' . $shopId;
35
        }
36
37
        return $this->delegate(
38
            new ShopwareCommandDefinition('theme:compile', '-n ' . $arguments)
39
        );
40
    }
41
}