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 ( 0da638...f31b5a )
by
unknown
16:04
created

Search::searchByKey()   B

Complexity

Conditions 4
Paths 2

Size

Total Lines 22
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 22
rs 8.9197
cc 4
eloc 13
nc 2
nop 1
1
<?php
2
3
namespace app\models;
4
5
use app\components\search\SearchEvent;
6
use app\components\search\SearchInterface;
7
use Yii;
8
use yii\base\Model;
9
use yii\db\Query;
10
11
class Search extends Model
12
{
13
14
    const QUERY_SEARCH_PRODUCTS_BY_DESCRIPTION = 'query_search_products_by_description';
15
    const QUERY_SEARCH_PRODUCTS_BY_PROPERTY = 'query_search_products_by_property';
16
    const QUERY_SEARCH_PAGES_BY_DESCRIPTION = 'query_search_pages_by_description';
17
18
    public $q = '';
19
20
    public function attributeLabels()
21
    {
22
        return [
23
            'q' => \Yii::t('app', 'Do Search') . '...'
24
        ];
25
    }
26
27
    public function rules()
28
    {
29
        return [
30
            ['q', 'string', 'min' => 3, 'skipOnEmpty' => false],
31
        ];
32
    }
33
34
    public function searchByKey($key)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
35
    {
36
37
        $result = [];
38
        $module = Yii::$app->getModule('core');
39
40
        if (!empty($module->searchHandlers[$key])) {
41
            foreach ($module->searchHandlers[$key] as $class) {
42
                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...
43
                    $this->on($key, [$class, 'editQuery']);
44
                }
45
            }
46
            $event = new SearchEvent();
47
            $event->q = $this->q;
48
            $event->activeQuery = (new Query());
49
            $this->trigger($key, $event);
50
            $result = $event->getAll();
51
        }
52
53
        return $result;
54
55
    }
56
57
58
    public function searchProductsByProperty()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
59
    {
60
        return $this->searchByKey(self::QUERY_SEARCH_PRODUCTS_BY_PROPERTY);
61
    }
62
63
    public function searchProductsByDescription()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
64
    {
65
        return $this->searchByKey(self::QUERY_SEARCH_PRODUCTS_BY_DESCRIPTION);
66
    }
67
68
    public function searchPagesByDescription()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
69
    {
70
        return $this->searchByKey(self::QUERY_SEARCH_PAGES_BY_DESCRIPTION);
71
    }
72
}
73