Passed
Push — develop ( d429ec...3e77ee )
by Edwin
02:54
created

Order::update()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 2
crap 1
1
<?php
2
3
namespace ShopifyClient\Resource;
4
5
/**
6
 * https://help.shopify.com/api/reference/order
7
 */
8
class Order extends AbstractCrudResource
9
{
10
    /**
11
     * @var string
12
     */
13
    protected $resourceKeySingular = 'order';
14
15
    /**
16
     * @var string
17
     */
18
    protected $resourceKeyPleural = 'orders';
19
20
    /**
21
     * @var bool
22
     */
23
    protected $countable = true;
24
25
    /**
26
     * @var OrderRisk
27
     */
28
    public $risks;
29
30
    /**
31
     * @param float $id
32
     * @return array
33
     */
34 1
    public function open(float $id)
35
    {
36 1
        $response = $this->request('POST', sprintf('/admin/orders/%s/open.json', $id));
37
38 1
        return $response[$this->resourceKeySingular];
39
    }
40
41
    /**
42
     * @param float $id
43
     * @param array $params
44
     * @return array
45
     */
46 1
    public function close(float $id, array $params = [])
47
    {
48 1
        $response = $this->request('POST', sprintf('/admin/orders/%s/close.json', $id), [
49 1
            'body' => json_encode($params)
50
        ]);
51
52 1
        return $response[$this->resourceKeySingular];
53
    }
54
55
    /**
56
     * @param float $id
57
     * @param array $params
58
     * @return array
59
     */
60 1
    public function cancel(float $id, array $params = [])
61
    {
62 1
        $response = $this->request('POST', sprintf('/admin/orders/%s/cancel.json', $id), [
63 1
            'body' => json_encode($params)
64
        ]);
65
66 1
        return $response[$this->resourceKeySingular];
67
    }
68
}
69