Completed
Push — master ( 5cbdfb...f4c8d8 )
by Nikola
05:45
created

PropertyQueryBehavior::hasProp()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 15
rs 9.4285
cc 3
eloc 9
nc 4
nop 2
1
<?php
2
/**
3
 * @author Nikola Kostadinov<[email protected]>
4
 * Date: 02.08.2016
5
 * Time: 09:11 ч.
6
 */
7
8
namespace nkostadinov\taxonomy\behaviors;
9
10
11
use nkostadinov\taxonomy\models\TaxonomyTerms;
12
13
class PropertyQueryBehavior extends BaseTermBehavior
14
{
15
    public function hasProp($name, $value = null)
16
    {
17
        $this->joinTables();
18
19
20
        if(!empty($name))
21
            $this->getQuery()
22
                ->andFilterWhere([ TaxonomyTerms::tableName() . '.term' => $name ]);
23
24
        if(!empty($value))
25
            $this->getQuery()
26
                ->andFilterWhere([ $this->taxonomy->table . '.value' => $value ]);
27
28
        return $this->getQuery();
29
    }
30
}