OrganizationRepository   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 40
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
    public function findOneByName($name)
26
    {
27
        return $this
28
            ->createQueryBuilder('o')
29
            ->where('o.name = :name')
30
            ->setParameter('name', $name)
31
            ->getQuery()
32
            ->getOneOrNullResult();
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function findOneByCode($code)
39
    {
40
        return $this
41
            ->createQueryBuilder('o')
42
            ->where('o.code = :code')
43
            ->setParameter('code', $code)
44
            ->getQuery()
45
            ->getOneOrNullResult();
46
    }
47
48
    /**
49
     * {@inheritdoc}
50
     */
51
    public function findAvailable()
52
    {
53
        return $this
54
            ->createQueryBuilder('o')
55
            ->where('o.enabled = true')
56
            ->getQuery()
57
            ->getResult();
58
    }
59
}
60