Completed
Push — master ( ffb209...577704 )
by Andrii
05:01
created

PlanQuery   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 35
ccs 0
cts 19
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A attributesMap() 0 19 1
A initFrom() 0 7 1
1
<?php
2
3
namespace hiqdev\billing\hiapi\plan;
4
5
use hiqdev\billing\hiapi\models\Plan;
6
7
class PlanQuery extends \hiapi\query\Query
8
{
9
    /**
10
     * @var string
11
     */
12
    protected $modelClass = Plan::class;
13
14
    protected function attributesMap()
15
    {
16
        return [
17
            'id' => 'zt.obj_id',
18
            'name' => 'zt.name',
19
            'type' => [
20
                'name' => 'tt.name',
21
            ],
22
            'seller' => [
23
                'id' => 'zc.obj_id',
24
                'login' => 'zc.login',
25
                'seller' => [
26
                    'id' => 'cr.obj_id',
27
                    'login' => 'cr.login',
28
                ],
29
            ],
30
            'available_for' => new AvailableForField(),
31
        ];
32
    }
33
34
    public function initFrom()
35
    {
36
        return $this->from('tariff  zt')
37
            ->leftJoin('zref        tt', 'tt.obj_id = zt.type_id')
38
            ->leftJoin('zclient     zc', 'zc.obj_id = zt.client_id')
39
            ->leftJoin('zclient     cr', 'cr.obj_id = zc.seller_id');
40
    }
41
}
42