Customer::update()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 8
Ratio 100 %

Importance

Changes 0
Metric Value
dl 8
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 3
1
<?php
2
3
namespace Groove\Api;
4
5
use Groove\Api;
6
use Groove\Models\Customer as Model;
7
8 View Code Duplication
class Customer extends Api
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
9
{
10
    /**
11
     * List customers.
12
     *
13
     * @param  array $params
14
     * @return \Illuminate\Support\Collection
15
     */
16
    public function list($params = [])
17
    {
18
        $response = $this->client->get('customers', $params);
19
20
        return collect($response->customers)->transform(function ($customer) {
21
            return new Model($customer, $this->client);
22
        });
23
    }
24
25
    /**
26
     * Find a customer.
27
     *
28
     * @param  string $email
29
     * @return Model
30
     */
31
    public function find($email)
32
    {
33
        $response = $this->client->get("customers/$email");
34
35
        return new Model($response->customer, $this->client);
36
    }
37
38
    /**
39
     * Update a customer.
40
     *
41
     * @param  string $existingEmail
42
     * @param  string $updatedEmail
43
     * @param  array $params
44
     * @return Model
45
     */
46
    public function update($existingEmail, $updatedEmail, $params = [])
47
    {
48
        $params = array_merge(['email' => $updatedEmail], $params);
49
50
        $response = $this->client->put("customers/$existingEmail", $params);
51
52
        return new Model($response->customer, $this->client);
53
    }
54
}
55