Completed
Push — master ( 7cff7c...eface1 )
by Olivier
04:30
created

TaxRate   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 54.55%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 35
loc 35
ccs 6
cts 11
cp 0.5455
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 6 6 1
A create() 9 9 1
A all() 6 6 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\TaxRate\TaxRate as TaxRateModel;
15
use Shapin\Stripe\Model\TaxRate\TaxRateCollection;
16
use Symfony\Component\Config\Definition\Processor;
17
18 View Code Duplication
final class TaxRate 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/tax_rates/$id");
26
27 1
        return $this->hydrator->hydrate($response, TaxRateModel::class);
28
    }
29
30
    /**
31
     * @throws Exception
32
     */
33
    public function create(array $params)
34
    {
35
        $processor = new Processor();
36
        $processor->processConfiguration(new Configuration\TaxRateCreate(), [$params]);
37
38
        $response = $this->httpPost('/v1/tax_rates', $params);
39
40
        return $this->hydrator->hydrate($response, TaxRateModel::class);
41
    }
42
43
    /**
44
     * @throws Exception
45
     */
46 1
    public function all(array $params = [])
47
    {
48 1
        $response = $this->httpGet('/v1/tax_rates', $params);
49
50 1
        return $this->hydrator->hydrate($response, TaxRateCollection::class);
51
    }
52
}
53