Completed
Pull Request — master (#15)
by Wachter
07:51
created

TaskRepository::findEndBeforeNow()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of php-task library.
5
 *
6
 * (c) php-task
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace Task\TaskBundle\DoctrineStorage;
13
14
use Doctrine\Common\Persistence\ObjectManager;
15
use Task\Storage\TaskRepositoryInterface;
16
use Task\TaskBundle\Entity\TaskRepository as ORMTaskRepository;
17
use Task\TaskInterface;
18
19
/**
20
 * Task storage which uses doctrine.
21
 */
22
class TaskRepository implements TaskRepositoryInterface
23
{
24
    /**
25
     * @var ObjectManager
26
     */
27
    private $objectManager;
28
29
    /**
30
     * @var ORMTaskRepository
31
     */
32
    private $taskRepository;
33
34
    /**
35
     * @param ObjectManager $objectManager
36
     * @param ORMTaskRepository $taskRepository
37
     */
38
    public function __construct(ObjectManager $objectManager, ORMTaskRepository $taskRepository)
39
    {
40
        $this->objectManager = $objectManager;
41
        $this->taskRepository = $taskRepository;
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47
    public function store(TaskInterface $task)
48
    {
49
        $this->objectManager->persist($task);
50
        $this->objectManager->flush();
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56
    public function findAll($limit = null)
57
    {
58
        return $this->taskRepository->findBy([], null, $limit);
59
    }
60
61
    /**
62
     * {@inheritdoc}
63
     */
64
    public function findEndBeforeNow()
65
    {
66
        return $this->taskRepository->findEndBefore(new \DateTime());
67
    }
68
}
69