Passed
Branch main (b0ee7b)
by Gaetano
09:00
created

WorkflowTrigger   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 6
c 2
b 0
f 0
dl 0
loc 18
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A receive() 0 3 1
A __construct() 0 3 1
A signalNameFromSignal() 0 4 1
1
<?php
2
3
namespace Kaliop\eZWorkflowEngineBundle\Core\Slot;
4
5
use eZ\Publish\Core\SignalSlot\Slot;
6
use eZ\Publish\Core\SignalSlot\Signal;
7
8
class WorkflowTrigger extends Slot
9
{
10
    protected $workflowService;
11
12
    public function __construct($workflowService)
13
    {
14
        $this->workflowService = $workflowService;
15
    }
16
17
    public function receive(Signal $signal)
18
    {
19
        return $this->workflowService->triggerWorkflow($this->signalNameFromSignal($signal), (array)$signal);
20
    }
21
22
    protected function signalNameFromSignal(Signal $signal)
23
    {
24
        $className = get_class($signal);
25
        return str_replace('eZ\Publish\Core\SignalSlot\Signal\\', '', $className);
26
    }
27
}
28