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.

Search::attributeLabels()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace app\models;
4
5
use app\components\search\SearchEvent;
6
use app\components\search\SearchInterface;
7
use app\modules\core\CoreModule;
8
use Yii;
9
use yii\base\Model;
10
use yii\db\Query;
11
12
class Search extends Model
13
{
14
15
    const QUERY_SEARCH_PRODUCTS_BY_DESCRIPTION = 'query_search_products_by_description';
16
    const QUERY_SEARCH_PRODUCTS_BY_PROPERTY = 'query_search_products_by_property';
17
    const QUERY_SEARCH_PAGES_BY_DESCRIPTION = 'query_search_pages_by_description';
18
19
    public $q = '';
20
21
    public function attributeLabels()
22
    {
23
        return [
24
            'q' => \Yii::t('app', 'Do Search') . '...'
25
        ];
26
    }
27
28
    public function rules()
29
    {
30
        return [
31
            ['q', 'string', 'min' => 3, 'skipOnEmpty' => false],
32
        ];
33
    }
34
35
    public function searchByKey($key)
36
    {
37
38
        $result = [];
39
        /**
40
         * @var $module CoreModule;
41
         */
42
        $module = Yii::$app->getModule('core');
43
44
        if (!empty($module->searchHandlers[$key])) {
45
            foreach ($module->searchHandlers[$key] as $class) {
46
                if (is_subclass_of($class, SearchInterface::class)) {
0 ignored issues
show
Bug introduced by
Due to PHP Bug #53727, is_subclass_of might return inconsistent results on some PHP versions if \app\components\search\SearchInterface::class can be an interface. If so, you could instead use ReflectionClass::implementsInterface.
Loading history...
47
                    $this->on($key, [$class, 'editQuery']);
48
                }
49
            }
50
            $event = new SearchEvent();
51
            $event->q = $this->q;
52
            $event->activeQuery = (new Query());
53
            $this->trigger($key, $event);
54
            $result = $event->getAll();
55
        }
56
57
        return $result;
58
59
    }
60
61
62
    public function searchProductsByProperty()
63
    {
64
        return $this->searchByKey(self::QUERY_SEARCH_PRODUCTS_BY_PROPERTY);
65
    }
66
67
    public function searchProductsByDescription()
68
    {
69
        return $this->searchByKey(self::QUERY_SEARCH_PRODUCTS_BY_DESCRIPTION);
70
    }
71
72
    public function searchPagesByDescription()
73
    {
74
        return $this->searchByKey(self::QUERY_SEARCH_PAGES_BY_DESCRIPTION);
75
    }
76
}
77