Passed
Push — master ( ba7534...9d8bf3 )
by Antônio
01:47
created

RetornosCliente::getRetornoDados()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 9
nc 2
nop 2
dl 0
loc 14
rs 9.4285
c 0
b 0
f 0
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
     * Pega todos os arquivos de retornos já enviado para a API
13
     * 
14
     * @return \OBRSDK\Entidades\Retornos[]
15
     */
16
    public function getListaRetornos() {
17
        $resposta = $this->apiCliente->addAuthorization()
18
                        ->get('retornos')->getResposta(true);
19
20
        $retornos = [];
21
        foreach ($resposta->retornos as $retorno) {
22
            $retornoObjeto = new \OBRSDK\Entidades\Retornos();
23
            $retornoObjeto->setAtributos($retorno);
24
25
            $retornos[] = $retornoObjeto;
26
        }
27
28
        return $retornos;
29
    }
30
31
    /**
32
     * Se passado o parametro isFile como true, a identificacao deve ser 
33
     * o caminho para o arquivo.
34
     * Se não, deve ser o ID de retorno enviado anteriormente
35
     * 
36
     * @param string $identificacao
37
     * @param bool $isFile
38
     * @return \OBRSDK\Entidades\Retornos
39
     */
40
    public function getRetornoDados($identificacao, $isFile = false) {
41
        $this->apiCliente->addAuthorization();
42
        if ($isFile) {
43
            $this->apiCliente->enviarArquivo('retornos', $identificacao);
44
        } else {
45
            $this->apiCliente->get('retornos/' . $identificacao);
46
        }
47
48
        $resposta = $this->apiCliente->getResposta(true);
49
50
        $respostaEntidade = new \OBRSDK\Entidades\Retornos();
51
        $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

51
        $respostaEntidade->setAtributos(/** @scrutinizer ignore-type */ $resposta);
Loading history...
52
53
        return $respostaEntidade;
54
    }
55
56
}
57