Completed
Pull Request — master (#15)
by Wachter
14:25 queued 04:03
created

TaskRepository::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
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