PagamentoExternoApi   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 48.57 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 4
dl 17
loc 35
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getByFiltros() 17 17 3

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
namespace Integracao\ControlPay\API;
4
5
use GuzzleHttp\Exception\RequestException;
6
use Integracao\ControlPay\AbstractAPI;
7
use Integracao\ControlPay\Client;
8
use Integracao\ControlPay\Helpers\SerializerHelper;
9
use Integracao\ControlPay\Contracts;
10
11
/**
12
 * Class PagamentoExternoApi
13
 * @package Integracao\ControlPay\API
14
 */
15
class PagamentoExternoApi extends AbstractAPI
16
{
17
18
    /**
19
     * PagamentoExternoApi constructor.
20
     */
21
    public function __construct(Client $client = null)
22
    {
23
        parent::__construct('pagamentoExterno', $client);
24
    }
25
26
    /**
27
     * @param Contracts\PagamentoExterno\GetByFiltrosRequest $getByFiltrosRequest
28
     * @return Contracts\PagamentoExterno\GetByFiltrosResponse
29
     * @throws \Exception
30
     */
31 View Code Duplication
    public function getByFiltros(Contracts\PagamentoExterno\GetByFiltrosRequest $getByFiltrosRequest)
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...
32
    {
33
        try{
34
            $this->response = $this->_httpClient->post(__FUNCTION__,[
35
                'body' => json_encode($getByFiltrosRequest),
36
            ]);
37
38
            return SerializerHelper::denormalize(
39
                $this->response->json(),
40
                Contracts\PagamentoExterno\GetByFiltrosResponse::class
41
            );
42
        }catch (RequestException $ex) {
43
            $this->requestException($ex);
44
        }catch (\Exception $ex){
45
            throw new \Exception($ex->getMessage(), $ex->getCode(), $ex);
46
        }
47
    }
48
49
}