Completed
Push — master ( 809938...77bf81 )
by Olivier
03:49
created

Invoice   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 83.33%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 3
dl 33
loc 33
ccs 10
cts 12
cp 0.8333
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 10 10 2
A all() 13 13 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\Configuration;
13
use Shapin\Stripe\Exception;
14
use Shapin\Stripe\Model\Invoice\Invoice as InvoiceModel;
15
use Shapin\Stripe\Model\Invoice\InvoiceCollection;
16
use Symfony\Component\Config\Definition\Processor;
17
18 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...
19
{
20
    /**
21
     * @throws Exception
22
     */
23 1
    public function get(string $id)
24
    {
25 1
        $response = $this->httpGet("/v1/invoices/$id");
26
27 1
        if (200 !== $response->getStatusCode()) {
28
            $this->handleErrors($response);
29
        }
30
31 1
        return $this->hydrator->hydrate($response, InvoiceModel::class);
32
    }
33
34
    /**
35
     * @throws Exception
36
     */
37 1
    public function all(array $params = [])
38
    {
39 1
        $processor = new Processor();
40 1
        $params = $processor->processConfiguration(new Configuration\InvoiceList(), [$params]);
41
42 1
        $response = $this->httpGet('/v1/invoices', $params);
43
44 1
        if (200 !== $response->getStatusCode()) {
45
            $this->handleErrors($response);
46
        }
47
48 1
        return $this->hydrator->hydrate($response, InvoiceCollection::class);
49
    }
50
}
51