ConfigQuery   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 4
eloc 11
c 2
b 0
f 1
dl 0
loc 26
ccs 0
cts 19
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getAvailable() 0 5 1
A withPrices() 0 6 1
A withSellerOptions() 0 9 2
1
<?php
2
/**
3
 * Server module for HiPanel
4
 *
5
 * @link      https://github.com/hiqdev/hipanel-module-server
6
 * @package   hipanel-module-server
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2019, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hipanel\modules\server\models\query;
12
13
use hiqdev\hiart\ActiveQuery;
14
use Yii;
15
16
class ConfigQuery extends ActiveQuery
17
{
18
    public function withPrices(): self
19
    {
20
        $this->joinWith('prices');
21
        $this->andWhere(['with_prices' => true]);
22
23
        return $this;
24
    }
25
26
    public function getAvailable(): self
27
    {
28
        $this->addAction('get-available');
29
30
        return $this;
31
    }
32
33
    public function withSellerOptions(): self
34
    {
35
        $options = Yii::$app->user->isGuest ? ['seller' => Yii::$app->params['user.seller']] : [
36
            'seller' => Yii::$app->user->identity->seller,
0 ignored issues
show
Bug introduced by
Accessing seller on the interface yii\web\IdentityInterface suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
37
            'seller_id' => Yii::$app->user->identity->seller_id,
0 ignored issues
show
Bug introduced by
Accessing seller_id on the interface yii\web\IdentityInterface suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
38
        ];
39
        $this->andWhere($options);
40
41
        return $this;
42
    }
43
}
44