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

Order::__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/order
10
 *
11
 * @method create(array $parameters = [])
12
 * @method get(float $parentId)
13
 * @method all(float $parentId)
14
 * @method count(float $parentId)
15
 * @method update(float $parentId, array $parameters = [])
16
 * @method open(float $parentId)
17
 * @method close(float $parentId)
18
 * @method cancel(float $parentId)
19
 * @method delete(float $parentId)
20
 *
21
 * @property OrderMetaField $metafields
22
 * @property OrderRisk $risks
23
 * @property Fulfillment $fulfillments
24
 */
25
class Order extends AbstractResource implements Resource
26
{
27
    /**
28
     * @var array
29
     */
30
    protected $childResources = [
31
        'metafields'   => OrderMetaField::class,
32
        'risks'        => OrderRisk::class,
33
        'fulfillments' => Fulfillment::class,
34
    ];
35
36
    /**
37
     * Order constructor.
38
     * @param Request $request
39
     */
40 5
    public function __construct(Request $request)
41
    {
42 5
        parent::__construct($request);
43
44 5
        $this->actions->add(
45 5
            'create',
46 5
            new Action(
47 5
                Request::METHOD_POST,
48 5
                'orders.json',
49 5
                'order',
50 5
                'order'
51
            )
52
        );
53 5
        $this->actions->add(
54 5
            'get',
55 5
            new Action(
56 5
                Request::METHOD_GET,
57 5
                'orders/%s.json',
58 5
                'order',
59 5
                'order'
60
            )
61
        );
62 5
        $this->actions->add(
63 5
            'all',
64 5
            new Action(
65 5
                Request::METHOD_GET,
66 5
                'orders.json',
67 5
                'orders',
68 5
                'orders'
69
            )
70
        );
71 5
        $this->actions->add(
72 5
            'count',
73 5
            new Action(
74 5
                Request::METHOD_GET,
75 5
                'orders/count.json',
76 5
                'count',
77 5
                'count'
78
            )
79
        );
80 5
        $this->actions->add(
81 5
            'update',
82 5
            new Action(
83 5
                Request::METHOD_PUT,
84 5
                'orders/%s.json',
85 5
                'order',
86 5
                'order'
87
            )
88
        );
89 5
        $this->actions->add(
90 5
            'open',
91 5
            new Action(
92 5
                Request::METHOD_POST,
93 5
                'orders/%s/open.json',
94 5
                'order',
95 5
                'order'
96
            )
97
        );
98 5
        $this->actions->add(
99 5
            'close',
100 5
            new Action(
101 5
                Request::METHOD_POST,
102 5
                'orders/%s/close.json',
103 5
                'order',
104 5
                'order'
105
            )
106
        );
107 5
        $this->actions->add(
108 5
            'cancel',
109 5
            new Action(
110 5
                Request::METHOD_POST,
111 5
                'orders/%s/cancel.json',
112 5
                'order',
113 5
                'order'
114
            )
115
        );
116 5
        $this->actions->add(
117 5
            'delete',
118 5
            new Action(
119 5
                Request::METHOD_DELETE,
120 5
                'orders/%s.json'
121
            )
122
        );
123 5
    }
124
125
126
}
127