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

OrganizationRepository   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 40
ccs 17
cts 17
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A findOneByName() 0 9 1
A findOneByCode() 0 9 1
A findAvailable() 0 8 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