ScheduleRepository::findNotInNames()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Glooby\TaskBundle\Entity;
4
5
use Doctrine\ORM\EntityRepository;
6
use Doctrine\ORM\NoResultException;
7
use Glooby\TaskBundle\Model\ScheduleInterface;
8
9
/**
10
 * @author Emil Kilhage
11
 */
12
class ScheduleRepository extends EntityRepository
13
{
14
    /**
15
     * @param string $name
16
     *
17
     * @return ScheduleInterface
18
     *
19
     * @throws NoResultException
20
     */
21
    public function findByName($name)
22
    {
23
        return $this->getEntityManager()
24
            ->createQuery('SELECT r FROM GloobyTaskBundle:Schedule r WHERE r.name = :name')
25
            ->setParameter('name', $name)
26
            ->useQueryCache(true)
27
            ->getSingleResult();
28
    }
29
30
    /**
31
     * @param array $names
32
     *
33
     * @return ScheduleInterface[]
34
     */
35
    public function findNotInNames(array $names)
36
    {
37
        return $this->getEntityManager()
38
            ->createQuery('SELECT r FROM GloobyTaskBundle:Schedule r WHERE r.name NOT IN (:names)')
39
            ->setParameter('names', $names)
40
            ->useQueryCache(true)
41
            ->getResult();
42
    }
43
44
    /**
45
     * @return ScheduleInterface[]
46
     */
47
    public function findActive()
48
    {
49
        return $this->getEntityManager()
50
            ->createQuery('SELECT r FROM GloobyTaskBundle:Schedule r WHERE r.active = true')
51
            ->useQueryCache(true)
52
            ->getResult();
53
    }
54
}
55