Passed
Push — master ( a8bd15...2c03c7 )
by Antônio
02:13
created

RetornosCliente   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 52.94 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 18
loc 34
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A enviarArquivoRetorno() 9 9 1
A getRetorno() 8 8 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
namespace OBRSDK\HttpClient;
4
5
/**
6
 * @author Antonio
7
 * @since 19/10/2017
8
 */
9
class RetornosCliente extends Nucleo\Instancia {
10
11
    /**
12
     * Faz o upload do arquivo de retorno do banco para a API
13
     * 
14
     * @param string $arquivo
15
     * @return \OBRSDK\Entidades\Retornos Lista de boletos e propriedades que 
16
     * foram processados pelo arquivo de retorno
17
     */
18 View Code Duplication
    public function enviarArquivoRetorno($arquivo) {
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...
19
        $resposta = $this->apiCliente->addAuthorization()
20
                ->enviarArquivo('retornos', $arquivo)
21
                ->getResposta(true);
22
23
        $respostaEntidade = new \OBRSDK\Entidades\Retornos();
24
        $respostaEntidade->setAtributos($resposta);
0 ignored issues
show
Bug introduced by
It seems like $resposta can also be of type object; however, parameter $atributos of OBRSDK\Entidades\Abstrat...himento::setAtributos() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

24
        $respostaEntidade->setAtributos(/** @scrutinizer ignore-type */ $resposta);
Loading history...
25
26
        return $respostaEntidade;
27
    }
28
29
    /**
30
     * Pega dados de retorno enviado anteriormente
31
     * 
32
     * @param string $retornoId
33
     * @return \OBRSDK\Entidades\Retornos
34
     */
35 View Code Duplication
    public function getRetorno($retornoId) {
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...
36
        $resposta = $this->apiCliente->addAuthorization()
37
                ->get('retornos/' . $retornoId)
38
                ->getResposta(true);
39
40
        $respostaEntidade = new \OBRSDK\Entidades\Retornos();
41
        $respostaEntidade->setAtributos($resposta);
0 ignored issues
show
Bug introduced by
It seems like $resposta can also be of type object; however, parameter $atributos of OBRSDK\Entidades\Abstrat...himento::setAtributos() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

41
        $respostaEntidade->setAtributos(/** @scrutinizer ignore-type */ $resposta);
Loading history...
42
        return $respostaEntidade;
43
    }
44
45
}
46