Test Failed
Push — develop ( 1bc728...a00b17 )
by Edwin
03:32
created

DiscountCode::__construct()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 84
Code Lines 63

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 64
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 84
ccs 64
cts 64
cp 1
rs 8.7169
c 0
b 0
f 0
cc 1
eloc 63
nc 1
nop 1
crap 1

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace ShopifyClient\Resource;
4
5
use ShopifyClient\Action\Action;
6
use ShopifyClient\Request;
7
8
/**
9
 * https://help.shopify.com/api/reference/discountcode
10
 *
11
 * @method create(array $parameters = [])
12
 * @method createBatch(float $parentId, array $parameters = [])
13
 * @method get(float $parentId)
14
 * @method getBatch(float $parentId, float $childId)
15
 * @method all(float $parentId)
16
 * @method allBatch(float $parentId, float $childId)
17
 * @method lookup(float $parentId, array $parameters = [])
18
 * @method count(float $parentId)
19
 * @method update(float $parentId, array $parameters = [])
20
 * @method delete(float $parentId)
21
 */
22
class DiscountCode extends AbstractResource implements Resource
23
{
24
    /**
25
     * DiscountCode constructor.
26
     * @param Request $request
27
     */
28 5
    public function __construct(Request $request)
29
    {
30 5
        parent::__construct($request);
31
32 5
        $this->actions->add(
33 5
            'create',
34 5
            new Action(
35 5
                Request::METHOD_POST,
36 5
                'price_rules/%s/discount_codes.json',
37 5
                'discount_code',
38 5
                'discount_code'
39
            )
40
        );
41 5
        $this->actions->add(
42 5
            'createBatch',
43 5
            new Action(
44 5
                Request::METHOD_POST,
45 5
                'price_rules/%s/batch.json',
46 5
                'discount_code_creation',
47 5
                'discount_codes'
48
            )
49
        );
50 5
        $this->actions->add(
51 5
            'get',
52 5
            new Action(
53 5
                Request::METHOD_GET,
54 5
                'price_rules/%s/discount_codes/%s.json',
55 5
                'discount_code',
56 5
                'discount_code'
57
            )
58
        );
59 5
        $this->actions->add(
60 5
            'getBatch',
61 5
            new Action(
62 5
                Request::METHOD_GET,
63 5
                'price_rules/%s/batch/%s.json',
64 5
                'discount_code_creation',
65 5
                'discount_code_creation'
66
            )
67
        );
68 5
        $this->actions->add(
69 5
            'all',
70 5
            new Action(
71 5
                Request::METHOD_GET,
72 5
                'price_rules/%s/discount_codes.json',
73 5
                'discount_codes',
74 5
                'discount_codes'
75
            )
76
        );
77 5
        $this->actions->add(
78 5
            'allBatch',
79 5
            new Action(
80 5
                Request::METHOD_GET,
81 5
                'price_rules/%s/batch/%s/discount_codes.json',
82 5
                'discount_codes',
83 5
                'discount_codes'
84
            )
85
        );
86 5
        $this->actions->add(
87 5
            'lookup',
88 5
            new Action(
89 5
                Request::METHOD_GET,
90 5
                'discount_codes/lookup.json',
91 5
                'discount_code',
92 5
                'discount_code'
93
            )
94
        );
95 5
        $this->actions->add(
96 5
            'update',
97 5
            new Action(
98 5
                Request::METHOD_PUT,
99 5
                'price_rules/%s/discount_codes/%s.json',
100 5
                'discount_code',
101 5
                'discount_code'
102
            )
103
        );
104 5
        $this->actions->add(
105 5
            'delete',
106 5
            new Action(
107 5
                Request::METHOD_DELETE,
108 5
                'price_rules/%s/discount_codes/%s.json'
109
            )
110
        );
111 5
    }
112
}
113