Completed
Push — master ( ce2be0...7bcb9a )
by Olivier
02:08
created

Invoice   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 80%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 30
loc 30
ccs 8
cts 10
cp 0.8
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 10 10 2
A all() 10 10 2

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\Exception;
13
use Shapin\Stripe\Model\Invoice\Invoice as InvoiceModel;
14
use Shapin\Stripe\Model\Invoice\InvoiceCollection;
15
16 View Code Duplication
final class Invoice extends HttpApi
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...
17
{
18
    /**
19
     * @throws Exception
20
     */
21 1
    public function get(string $id)
22
    {
23 1
        $response = $this->httpGet("/v1/invoices/$id");
24
25 1
        if (200 !== $response->getStatusCode()) {
26
            $this->handleErrors($response);
27
        }
28
29 1
        return $this->hydrator->hydrate($response, InvoiceModel::class);
30
    }
31
32
    /**
33
     * @throws Exception
34
     */
35 1
    public function all(array $params = [])
36
    {
37 1
        $response = $this->httpGet('/v1/invoices'.http_build_query($params));
38
39 1
        if (200 !== $response->getStatusCode()) {
40
            $this->handleErrors($response);
41
        }
42
43 1
        return $this->hydrator->hydrate($response, InvoiceCollection::class);
44
    }
45
}
46