Passed
Push — master ( 151800...a77de0 )
by Dāvis
03:07
created

AdminTrait::getRedis()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
c 0
b 0
f 0
nc 2
nop 0
dl 0
loc 11
rs 9.4285
1
<?php
2
3
namespace Sludio\HelperBundle\Translatable\Admin;
4
use Sludio\HelperBundle\Translatable\Entity\BaseEntity;
5
6
trait AdminTrait
7
{
8
    public function getTranslationFilter($queryBuilder, $alias, $field, $value)
9
    {
10
        if (!isset($value['value'])) {
11
            return false;
12
        }
13
        $queryBuilder->leftJoin('Sludio:Translation', 't', 'WITH', 't.foreignKey = '.$alias.'.id');
14
        $queryBuilder->andWhere("t.field = '$field'");
15
        $queryBuilder->andWhere("t.objectClass = '".$this->getClass()."'");
0 ignored issues
show
Bug introduced by
It seems like getClass() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

15
        $queryBuilder->andWhere("t.objectClass = '".$this->/** @scrutinizer ignore-call */ getClass()."'");
Loading history...
16
        $queryBuilder->andWhere("t.content LIKE '%".$value['value']."%'");
17
        $queryBuilder->setFirstResult(0);
18
19
        return true;
20
    }
21
}