Customer   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 58
Duplicated Lines 15.52 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 47.37%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 5
dl 9
loc 58
ccs 9
cts 19
cp 0.4737
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 6 1
A all() 0 6 1
A update() 0 9 1
A delete() 0 6 1
A create() 9 9 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This software may be modified and distributed under the terms
7
 * of the MIT license. See the LICENSE file for details.
8
 */
9
10
namespace Shapin\Stripe\Api;
11
12
use Shapin\Stripe\Configuration;
13
use Shapin\Stripe\Exception;
14
use Shapin\Stripe\Model\Customer\Customer as CustomerModel;
15
use Shapin\Stripe\Model\Customer\CustomerCollection;
16
use Shapin\Stripe\Model\Customer\CustomerDeleted;
17
use Symfony\Component\Config\Definition\Processor;
18
19
final class Customer extends HttpApi
20
{
21
    /**
22
     * @throws Exception
23
     */
24 1
    public function get(string $customerId)
25
    {
26 1
        $response = $this->httpGet("customers/$customerId");
27
28 1
        return $this->hydrator->hydrate($response, CustomerModel::class);
29
    }
30
31
    /**
32
     * @throws Exception
33
     */
34 1
    public function all(array $params = [])
35
    {
36 1
        $response = $this->httpGet('customers', $params);
37
38 1
        return $this->hydrator->hydrate($response, CustomerCollection::class);
39
    }
40
41
    /**
42
     * @throws Exception
43
     */
44 View Code Duplication
    public function create(array $params)
0 ignored issues
show
Duplication introduced by
This method 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...
45
    {
46
        $processor = new Processor();
47
        $params = $processor->processConfiguration(new Configuration\CustomerCreate(), [$params]);
48
49
        $response = $this->httpPost('customers', $params);
50
51
        return $this->hydrator->hydrate($response, CustomerModel::class);
52
    }
53
54
    /**
55
     * @throws Exception
56
     */
57
    public function update(string $id, array $params)
58
    {
59
        $processor = new Processor();
60
        $params = $processor->processConfiguration(new Configuration\CustomerUpdate(), [$params]);
61
62
        $response = $this->httpPost("customers/$id", $params);
63
64
        return $this->hydrator->hydrate($response, CustomerModel::class);
65
    }
66
67
    /**
68
     * @throws Exception
69
     */
70 1
    public function delete(string $id)
71
    {
72 1
        $response = $this->httpDelete("customers/$id");
73
74 1
        return $this->hydrator->hydrate($response, CustomerDeleted::class);
75
    }
76
}
77