GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Test Setup Failed
Push — filters ( d405d9...e854eb )
by
unknown
09:25
created

SearchProductsByPropertyHandler::editQuery()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 45
Code Lines 26

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 1
Metric Value
c 2
b 1
f 1
dl 0
loc 45
rs 8.8571
cc 2
eloc 26
nc 2
nop 1
1
<?php
2
3
namespace app\components\search;
4
5
6
use app\models\Object;
7
use app\models\ObjectStaticValues;
8
use app\models\PropertyStaticValues;
9
use app\modules\shop\models\Product;
10
use yii\db\Query;
11
use yii\helpers\ArrayHelper;
12
13
class SearchProductsByPropertyHandler implements SearchInterface
14
{
15
    public static function editQuery(SearchEvent $event)
16
    {
17
        /** @var \app\modules\shop\ShopModule $module */
18
        $module = \Yii::$app->modules['shop'];
19
20
        /** @var \app\modules\shop\ShopModule $module */
21
        $properties = (new Query())
22
            ->select('`id`')
23
            ->from(PropertyStaticValues::tableName())
24
            ->where('`name` LIKE :q')
25
            ->addParams([':q' => '%' . $event->q . '%'])
26
            ->all();
27
28
29
        $event->activeQuery->select('{{%object_static_values}}.object_model_id')
30
            ->distinct(true)
31
            ->from(ObjectStaticValues::tableName())
32
            ->where('{{%object_static_values}}.object_id = :objectId')
33
            ->addParams([':objectId' => Object::getForClass(Product::className())->id])
34
            ->andWhere([
35
                'in',
36
                '{{%object_static_values}}.property_static_value_id',
37
                ArrayHelper::getColumn($properties, 'id')
38
            ]);
39
40
        if ($module->allowSearchGeneratedProducts != 1) {
41
42
            $event->activeQuery->innerJoin(
43
                '{{%product}}',
44
                '{{%product}}.id = {{%object_static_values}}.object_model_id'
45
            );
46
47
            $event->activeQuery->andWhere(
48
                [
49
                    '{{%product}}.parent_id' => 0,
50
                    '{{%product}}.active' => 1
51
                ]
52
            );
53
        }
54
55
        $event->setFunctionSearch(function ($activeQuery) {
56
            return ArrayHelper::getColumn($activeQuery->all(), 'object_model_id');
57
        });
58
59
    }
60
}