Completed
Push — master ( b355d9...43cc45 )
by Andrii
02:30
created

SaleQuery   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 41
Duplicated Lines 21.95 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 9
loc 41
ccs 0
cts 31
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A attributesMap() 0 23 1
A initFrom() 9 9 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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\sale;
12
13
use hiqdev\billing\hiapi\models\Sale;
14
15
class SaleQuery extends \hiqdev\yii\DataMapper\query\Query
16
{
17
    /**
18
     * @var string
19
     */
20
    protected $modelClass = Sale::class;
21
22
    protected function attributesMap()
23
    {
24
        return [
25
            'id' => 'zs.obj_id',
26
            'target' => [
27
                'id' => 'zs.object_id',
28
                'type' => 'oc.name',
29
            ],
30
            'customer' => [
31
                'id' => 'zc.obj_id',
32
                'login' => 'zc.login',
33
                'seller' => [
34
                    'id' => 'cr.obj_id',
35
                    'login' => 'cr.login',
36
                ],
37
            ],
38
            'plan' => [
39
                'id' => 'zs.tariff_id',
40
                'name' => 'zt.tariff',
41
            ],
42
            //'available_for' => new AvailableForField(),
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
43
        ];
44
    }
45
46 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...
47
    {
48
        return $this->from('zsale   zs')
49
            ->leftJoin('obj         so', 'so.obj_id = zs.obj_id')
50
            ->leftJoin('zref        oc', 'oc.obj_id = so.class_id')
51
            ->leftJoin('ztariff     zt', 'zt.obj_id = zs.tariff_id')
52
            ->leftJoin('zclient     zc', 'zc.obj_id = zs.buyer_id')
53
            ->leftJoin('zclient     cr', 'cr.obj_id = zc.seller_id');
54
    }
55
}
56