Completed
Pull Request — master (#15)
by Wachter
08:17
created

TaskRepository   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 2

Importance

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

4 Methods

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