Completed
Push — master ( a682ba...4851b3 )
by Paweł
40:50
created

OrganizationRepository::findOneByName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 6
cts 6
cp 1
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 1
crap 1
1
<?php
2
3
/*
4
 * This file is part of the Superdesk Web Publisher MultiTenancy Bundle.
5
 *
6
 * Copyright 2016 Sourcefabric z.ú. and contributors.
7
 *
8
 * For the full copyright and license information, please see the
9
 * AUTHORS and LICENSE files distributed with this source code.
10
 *
11
 * @copyright 2016 Sourcefabric z.ú
12
 * @license http://www.superdesk.org/license
13
 */
14
15
namespace SWP\Bundle\MultiTenancyBundle\Doctrine\ORM;
16
17
use SWP\Bundle\StorageBundle\Doctrine\ORM\EntityRepository;
18
use SWP\Component\MultiTenancy\Repository\OrganizationRepositoryInterface;
19
20
class OrganizationRepository extends EntityRepository implements OrganizationRepositoryInterface
21
{
22
    /**
23
     * {@inheritdoc}
24
     */
25 7
    public function findOneByName($name)
26
    {
27
        return $this
28 7
            ->createQueryBuilder('o')
29 7
            ->where('o.name = :name')
30 7
            ->setParameter('name', $name)
31 7
            ->getQuery()
32 7
            ->getOneOrNullResult();
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38 1
    public function findOneByCode($code)
39
    {
40
        return $this
41 1
            ->createQueryBuilder('o')
42 1
            ->where('o.code = :code')
43 1
            ->setParameter('code', $code)
44 1
            ->getQuery()
45 1
            ->getOneOrNullResult();
46
    }
47
48
    /**
49
     * {@inheritdoc}
50
     */
51 6
    public function findAvailable()
52
    {
53
        return $this
54 6
            ->createQueryBuilder('o')
55 6
            ->where('o.enabled = true')
56 6
            ->getQuery()
57 6
            ->getResult();
58
    }
59
}
60