PlanQuery   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A initFrom() 0 6 1
A attributesMap() 0 18 1
1
<?php
2
/**
3
 * API for Billing
4
 *
5
 * @link      https://github.com/hiqdev/billing-hiapi
6
 * @package   billing-hiapi
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2017-2018, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\billing\hiapi\plan;
12
13
use hiqdev\billing\hiapi\models\Plan;
14
15
class PlanQuery extends \hiqdev\yii\DataMapper\query\Query
16
{
17
    /**
18
     * @var string
19
     */
20
    protected $modelClass = Plan::class;
21
22
    protected function attributesMap()
23
    {
24
        return [
25
            'id' => 'zt.obj_id',
26
            'name' => 'zt.name',
27
            'type' => [
28
                'name' => 'tt.name',
29
            ],
30
            'seller' => [
31
                'id' => 'zc.obj_id',
32
                'login' => 'zc.login',
33
                'seller' => [
34
                    'id' => 'cr.obj_id',
35
                    'login' => 'cr.login',
36
                ],
37
            ],
38
            'is_grouping' => 'zt.is_grouping',
39
            'available_for' => new AvailableForField(),
40
        ];
41
    }
42
43
    public function initFrom()
44
    {
45
        return $this->from('tariff  zt')
46
            ->leftJoin('zref        tt', 'tt.obj_id = zt.type_id')
47
            ->leftJoin('zclient     zc', 'zc.obj_id = zt.client_id')
48
            ->leftJoin('zclient     cr', 'cr.obj_id = zc.seller_id');
49
    }
50
}
51