Completed
Push — master ( 68f942...d69058 )
by Rafał
18:18
created

OrganizationRepository   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 3
dl 0
loc 40
rs 10

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
namespace SWP\Bundle\MultiTenancyBundle\Doctrine\ORM;
15
16
use SWP\Bundle\StorageBundle\Doctrine\ORM\EntityRepository;
17
use SWP\Component\MultiTenancy\Repository\OrganizationRepositoryInterface;
18
19
class OrganizationRepository extends EntityRepository implements OrganizationRepositoryInterface
20
{
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public function findOneByName($name)
25
    {
26
        return $this
27
            ->createQueryBuilder('o')
28
            ->where('o.name = :name')
29
            ->setParameter('name', $name)
30
            ->getQuery()
31
            ->getOneOrNullResult();
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37
    public function findOneByCode($code)
38
    {
39
        return $this
40
            ->createQueryBuilder('o')
41
            ->where('o.code = :code')
42
            ->setParameter('code', $code)
43
            ->getQuery()
44
            ->getOneOrNullResult();
45
    }
46
47
    /**
48
     * {@inheritdoc}
49
     */
50
    public function findAvailable()
51
    {
52
        return $this
53
            ->createQueryBuilder('o')
54
            ->where('o.enabled = true')
55
            ->getQuery()
56
            ->getArrayResult();
57
    }
58
}
59