Passed
Push — develop ( f86f45...dfc586 )
by Edwin
01:46
created

OrderRisk   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 75
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 75
ccs 21
cts 21
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 10 1
A all() 0 8 1
A create() 0 10 1
A update() 0 10 1
A delete() 0 4 1
1
<?php
2
3
namespace ShopifyClient\Resource;
4
5
/**
6
 * https://help.shopify.com/api/reference/order_risks
7
 */
8
class OrderRisk extends AbstractResource
9
{
10
    /**
11
     * @param float $orderId
12
     * @param float $id
13
     * @param array $fields
14
     * @return array
15
     */
16 1
    public function get(float $orderId, float $id, array $fields = [])
17
    {
18 1
        $response = $this->request('GET', sprintf('/admin/orders/%s/risks/%s.json', $orderId, $id), [
19
            'query' => [
20 1
                'fields' => $fields,
21
            ],
22
        ]);
23
24 1
        return $response['risk'];
25
    }
26
27
    /**
28
     * @param float $id
29
     * @param array $query
30
     * @return array
31
     */
32 1
    public function all(float $id, array $query = [])
33
    {
34 1
        $response = $this->request('GET', sprintf('/admin/orders/%s/risks.json', $id), [
35 1
            'query' => $query,
36
        ]);
37
38 1
        return $response['risks'];
39
    }
40
41
    /**
42
     * @param float $id
43
     * @param array $params
44
     * @return array
45
     */
46 1
    public function create(float $id, array $params = [])
47
    {
48 1
        $response = $this->request('POST', sprintf('/admin/orders/%s/risks.json', $id), [
49 1
            'body' => json_encode([
50 1
                'risk' => $params,
51
            ]),
52
        ]);
53
54 1
        return $response['risk'];
55
    }
56
57
    /**
58
     * @param float $orderId
59
     * @param float $id
60
     * @param array $params
61
     * @return array
62
     */
63 1
    public function update(float $orderId, float $id, array $params = [])
64
    {
65 1
        $response = $this->request('PUT', sprintf('/admin/orders/%s/risks/%s.json', $orderId, $id), [
66 1
            'body' => json_encode([
67 1
                'risk' => $params,
68
            ]),
69
        ]);
70
71 1
        return $response['risk'];
72
    }
73
74
    /**
75
     * @param float $orderId
76
     * @param float $id
77
     */
78 1
    public function delete(float $orderId, float $id)
79
    {
80 1
        $this->request('DELETE', sprintf('/admin/orders/%s/risks/%s.json', $orderId, $id));
81 1
    }
82
}
83