Completed
Push — master ( 9c7fd0...afc45c )
by Andrii
10:58
created

PriceQuery::initFrom()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 8

Duplication

Lines 10
Ratio 100 %

Importance

Changes 0
Metric Value
dl 10
loc 10
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 0
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, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\billing\hiapi\price;
12
13
use hiqdev\billing\hiapi\models\Price;
14
use yii\db\Expression;
15
16
class PriceQuery extends \hiqdev\yii\DataMapper\query\Query
17
{
18
    /**
19
     * @var string
20
     */
21
    protected $modelClass = Price::class;
22
23
    protected function attributesMap()
24
    {
25
        return [
26
            'id' => 'zp.id',
27
            'plan' => [
28
                'id' => 'zp.tariff_id',
29
            ],
30
            'target' => [
31
                'id' => 'zp.object_id',
32
                'type' => 'oc.name',
33
            ],
34
            'type' => [
35
                'id' => 'zp.type_id',
36
                'name' => 'rt.name',
37
            ],
38
            'price' => [
39
                'currency' => 'cu.name',
40
                'amount' => 'zp.price',
41
            ],
42
            'prepaid' => [
43
                'unit' => 'tu.name',
44
                'quantity' => 'zp.quantity',
45
            ],
46
            'data' => 'zp.data',
47
        ];
48
    }
49
50 View Code Duplication
    public function initFrom()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
51
    {
52
        return $this
53
            ->from('uprice              zp')
54
            ->leftJoin('zref            rt', 'rt.obj_id = zp.type_id')
55
            ->leftJoin('zref            tu', 'tu.obj_id = zp.unit_id')
56
            ->leftJoin('zref            cu', 'cu.obj_id = zp.currency_id')
57
            ->leftJoin('obj             zo', 'zo.obj_id = zp.object_id')
58
            ->leftJoin('zref            oc', 'oc.obj_id = zo.class_id');
59
    }
60
}
61