TaskManager   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 43
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A process() 0 11 1
1
<?php
2
3
namespace Jarobe\TaskRunnerBundle\Manager;
4
5
use Jarobe\TaskRunnerBundle\Entity\TaskEvent;
6
use Jarobe\TaskRunnerBundle\Entity\TaskEventInterface;
7
use Jarobe\TaskRunnerBundle\Hydrator\HydratorInterface;
8
use Jarobe\TaskRunnerBundle\Processor\ProcessorInterface;
9
10
/**
11
 * Responsible for processing a Task.
12
 */
13
class TaskManager
14
{
15
    /**
16
     * @var TaskEventManager
17
     */
18
    private $taskEventManager;
19
20
    /**
21
     * @var HydratorInterface
22
     */
23
    private $hydrator;
24
25
    /**
26
     * @var ProcessorInterface
27
     */
28
    private $processor;
29
30
    public function __construct(
31
        TaskEventManager $taskEventManager,
32
        HydratorInterface $hydrator,
33
        ProcessorInterface $processor
34
    ) {
35
        $this->taskEventManager = $taskEventManager;
36
        $this->hydrator = $hydrator;
37
        $this->processor = $processor;
38
    }
39
40
    /**
41
     * @param TaskEventInterface $taskEvent
42
     * @return TaskEventInterface
43
     */
44
    public function process(TaskEventInterface $taskEvent)
45
    {
46
        $this->taskEventManager->initiateTaskEvent($taskEvent);
47
48
        $task = $this->hydrator->getTaskFromTaskEvent($taskEvent);
49
        $result = $this->processor->process($task);
50
51
        $this->taskEventManager->updateTaskEventWithResult($taskEvent, $result);
52
53
        return $taskEvent;
54
    }
55
}
56