Brand   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 9
dl 0
loc 15
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A byImportAttributes() 0 13 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: execut
5
 * Date: 12/22/17
6
 * Time: 2:15 PM
7
 */
8
9
namespace execut\import\example\models\queries;
10
11
12
use execut\import\example\models\BrandsAlias;
13
use execut\import\Query;
14
use yii\db\ActiveQuery;
15
16
class Brand extends ActiveQuery implements Query
17
{
18
    public function byImportAttributes($attributes)
19
    {
20
        return $this
21
            ->with([
22
                'aliases' => function ($q) use ($attributes) {
23
                    return $q->andWhere($attributes);
24
                },
25
            ])
26
            ->andWhere([
27
            'OR',
28
            $attributes,
29
            [
30
                'id' => BrandsAlias::find()->select('id')->andWhere($attributes),
31
            ]
32
        ]);
33
    }
34
}