PropertyQueryBehavior::hasProp()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 9.7666
c 0
b 0
f 0
cc 3
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
}