Completed
Push — master ( 6718d9...b5055a )
by Rafał
14:45
created

TenantRepository::findOneByDomain()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 10

Duplication

Lines 12
Ratio 100 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 12
loc 12
rs 9.4285
cc 1
eloc 10
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of the Superdesk Web Publisher MultiTenancy Bundle.
5
 *
6
 * Copyright 2015 Sourcefabric z.u. 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 2015 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\TenantRepositoryInterface;
19
20
/**
21
 * Repository interface for tenants.
22
 */
23
class TenantRepository extends EntityRepository implements TenantRepositoryInterface
0 ignored issues
show
Bug introduced by
There is one abstract method findOneBySubdomain in this class; you could implement it, or declare this class as abstract.
Loading history...
24
{
25
    /**
26
     * {@inheritdoc}
27
     */
28 View Code Duplication
    public function findOneBySubdomainAndDomain($subdomain, $domain)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
29
    {
30
        return $this
31
            ->createQueryBuilder('t')
32
            ->select('t', 'o')
33
            ->leftJoin('t.organization', 'o')
34
            ->where('t.subdomain = :subdomain')
35
            ->andWhere('t.domainName = :domainName')
36
            ->setParameters([
37
                'subdomain' => $subdomain,
38
                'domainName' => $domain,
39
            ])
40
            ->getQuery()
41
            ->getOneOrNullResult();
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47 View Code Duplication
    public function findOneByDomain($domain)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
48
    {
49
        return $this
50
            ->createQueryBuilder('t')
51
            ->select('t', 'o')
52
            ->leftJoin('t.organization', 'o')
53
            ->where('t.domainName = :domainName')
54
            ->andWhere('t.subdomain IS NULL')
55
            ->setParameter('domainName', $domain)
56
            ->getQuery()
57
            ->getOneOrNullResult();
58
    }
59
60
    /**
61
     * {@inheritdoc}
62
     */
63
    public function findOneByCode($code)
64
    {
65
        return $this
66
            ->createQueryBuilder('t')
67
            ->select('t', 'o')
68
            ->leftJoin('t.organization', 'o')
69
            ->where('t.code = :code')
70
            ->setParameter('code', $code)
71
            ->getQuery()
72
            ->getOneOrNullResult();
73
    }
74
75
    /**
76
     * {@inheritdoc}
77
     */
78
    public function findAvailableTenants()
79
    {
80
        return $this
81
            ->createQueryBuilder('t')
82
            ->select('t', 'o')
83
            ->leftJoin('t.organization', 'o')
84
            ->getQuery()
85
            ->getArrayResult();
86
    }
87
}
88