CustomerManager   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 2
dl 0
loc 68
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getServiceName() 0 4 1
A getResourceName() 0 4 1
A getModelClass() 0 4 1
A createAccountActivationUrl() 0 6 1
A sendInvite() 0 8 1
A search() 0 6 1
A orders() 0 6 1
1
<?php
2
3
/*
4
 * This file is part of the slince/shopify-api-php
5
 *
6
 * (c) Slince <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace Slince\Shopify\Manager\Customer;
13
14
use Slince\Shopify\Common\Manager\GeneralCurdable;
15
use Slince\Shopify\Manager\Order\Order;
16
17
class CustomerManager extends GeneralCurdable implements CustomerManagerInterface
18
{
19
    /**
20
     * {@inheritdoc}
21
     */
22
    public static function getServiceName()
23
    {
24
        return 'customers';
25
    }
26
27
    /**
28
     * {@inheritdoc}
29
     */
30
    public function getResourceName()
31
    {
32
        return 'customer';
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function getModelClass()
39
    {
40
        return Customer::class;
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function createAccountActivationUrl($id)
47
    {
48
        $data = $this->client->post('customers/'.$id.'/account_activation_url', []);
49
50
        return $data['account_activation_url'];
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56
    public function sendInvite($id, array $data)
57
    {
58
        $data = $this->client->post('customers/'.$id.'/send_invite', [
59
            'customer_invite' => $data,
60
        ]);
61
62
        return $this->fromArray($data, CustomerInvite::class);
63
    }
64
65
    /**
66
     * {@inheritdoc}
67
     */
68
    public function search(array $query = [])
69
    {
70
        $data = $this->client->get('customers/search', $query);
71
72
        return $this->createMany(reset($data));
73
    }
74
75
    /**
76
     * {@inheritdoc}
77
     */
78
    public function orders($id)
79
    {
80
        $data = $this->client->get('customers/'.$id.'/orders');
81
82
        return $this->createMany(reset($data), Order::class);
83
    }
84
}
85