Completed
Pull Request — master (#15)
by Wachter
06:00
created

TaskExecutionRepository   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 2
cbo 2
dl 0
loc 45
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A save() 0 5 1
A add() 0 4 1
A findScheduled() 0 4 1
A findByStartTime() 0 4 1
1
<?php
2
3
namespace Task\TaskBundle\DoctrineStorage;
4
5
use Doctrine\Common\Persistence\ObjectManager;
6
use Task\Execution\TaskExecutionInterface;
7
use Task\Storage\TaskExecutionRepositoryInterface;
8
use Task\TaskBundle\Entity\TaskExecutionRepository as ORMTaskExecutionRepository;
9
use Task\TaskInterface;
10
11
class TaskExecutionRepository implements TaskExecutionRepositoryInterface
12
{
13
    /**
14
     * @var ObjectManager
15
     */
16
    private $objectManager;
17
18
    /**
19
     * @var ORMTaskExecutionRepository
20
     */
21
    private $taskExecutionRepository;
22
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function save(TaskExecutionInterface $execution)
27
    {
28
        $this->objectManager->persist($execution);
29
        $this->objectManager->flush();
30
    }
31
32
    /**
33
     * {@inheritdoc}
34
     */
35
    public function add(TaskExecutionInterface $execution)
36
    {
37
        $this->objectManager->flush();
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43
    public function findScheduled()
44
    {
45
        return $this->taskExecutionRepository->findScheduled(new \DateTime);
46
    }
47
48
    /**
49
     * {@inheritdoc}
50
     */
51
    public function findByStartTime(TaskInterface $task, \DateTime $scheduleTime)
52
    {
53
        return $this->taskExecutionRepository->findByStartTime($task, $scheduleTime);
54
    }
55
}
56