Test Failed
Push — develop ( 9e3f9b...05a047 )
by Edwin
02:28
created

CustomerAddress   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 71
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 71
ccs 19
cts 19
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 8 1
A update() 0 8 1
A delete() 0 4 1
1
<?php
2
3
namespace ShopifyClient\Resource;
4
5
/**
6
 * https://help.shopify.com/api/reference/customeraddress
7
 */
8
class CustomerAddress extends AbstractResource
9
{
10
    /**
11
     * @param float $customerId
12
     * @param float $id
13
     * @param array $fields
14
     * @return array
15
     */
16 1
    public function get(float $customerId, float $id, array $fields = [])
17
    {
18 1
        $response = $this->request('GET', sprintf('/admin/customers/%s/addresses/%s.json', $customerId, $id), [
19
            'query' => [
20 1
                'fields' => $fields,
21
            ],
22
        ]);
23
24 1
        return $response['customer_address'];
25
    }
26
27
    /**
28
     * @param float $id customer 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/customers/%s/addresses.json', $id), [
35 1
            'query' => $query,
36
        ]);
37
38 1
        return $response['addresses'];
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/customers/%s/addresses.json', $id), [
49 1
            'body' => json_encode(['address' => $params]),
50
        ]);
51
52 1
        return $response['customer_address'];
53
    }
54
55
    /**
56
     * @param float $customerId
57
     * @param float $id
58
     * @param array $params
59
     * @return array
60
     */
61 1
    public function update(float $customerId, float $id, array $params = [])
62
    {
63 1
        $response = $this->request('PUT', sprintf('/admin/customers/%s/addresses/%s.json', $customerId, $id), [
64 1
            'body' => json_encode(['address' => $params]),
65
        ]);
66
67 1
        return $response['customer_address'];
68
    }
69
70
    /**
71
     * @param float $customerId
72
     * @param float $id
73
     */
74 1
    public function delete(float $customerId, float $id)
75
    {
76 1
        $this->request('DELETE', sprintf('/admin/customers/%s/addresses/%s.json', $customerId, $id));
77 1
    }
78
}
79