Completed
Pull Request — master (#1)
by Rafał
03:36 queued 01:22
created

TenantableFilter   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A addFilterConstraint() 0 12 3
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
namespace SWP\MultiTenancyBundle\Query\Filter;
15
16
use Doctrine\ORM\Mapping\ClassMetadata;
17
use Doctrine\ORM\Query\Filter\SQLFilter;
18
19
/**
20
 * Tenantable Filter class.
21
 */
22
class TenantableFilter extends SQLFilter
23
{
24
    /**
25
     * {@inheritdoc}
26
     */
27
    public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias)
28
    {
29
        if (!$targetEntity->reflClass->implementsInterface('SWP\Component\MultiTenancy\Model\TenantAwareInterface')) {
30
            return '';
31
        }
32
33
        if ($this->hasParameter('tenantId')) {
0 ignored issues
show
Bug introduced by
The method hasParameter() does not seem to exist on object<SWP\MultiTenancyB...ilter\TenantableFilter>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
34
            return $targetTableAlias.'.tenant_id = '.$this->getParameter('tenantId');
35
        }
36
37
        return '';
38
    }
39
}
40