Code Duplication    Length = 24-25 lines in 3 locations

src/Tools.php 3 locations

@@ 67-90 (lines=24) @@
64
     * @param string $tpAmb
65
     * @return   string
66
     */
67
    public function sefazConsultaRecibo($recibo, $tpAmb = null)
68
    {
69
        if (empty($tpAmb)) {
70
            $tpAmb = $this->tpAmb;
71
        }
72
        //carrega serviço
73
        $servico = 'MDFeRetRecepcao';
74
        $this->servico(
75
            $servico,
76
            $this->config->siglaUF,
77
            $tpAmb
78
        );
79
        $request = "<consReciMDFe xmlns=\"$this->urlPortal\" versao=\"$this->urlVersion\">"
80
            . "<tpAmb>$tpAmb</tpAmb>"
81
            . "<nRec>$recibo</nRec>"
82
            . "</consReciMDFe>";
83
        $this->isValid($this->urlVersion, $request, 'consReciMDFe');
84
        //montagem dos dados da mensagem SOAP
85
        $this->lastRequest = $request;
86
        $parameters = ['mdfeDadosMsg' => $request];
87
        $body = "<mdfeDadosMsg xmlns=\"$this->urlNamespace\">$request</mdfeDadosMsg>";
88
        $this->lastResponse = $this->sendRequest($body, $parameters);
89
        return $this->lastResponse;
90
    }
91
92
    /**
93
     * @author Cleiton Perin
@@ 100-123 (lines=24) @@
97
     * @param string $tpAmb
98
     * @return   string
99
     */
100
    public function sefazConsultaChave($chave, $tpAmb = null)
101
    {
102
        if (empty($tpAmb)) {
103
            $tpAmb = $this->tpAmb;
104
        }
105
        //carrega serviço
106
        $servico = 'MDFeConsulta';
107
        $this->servico(
108
            $servico,
109
            $this->config->siglaUF,
110
            $tpAmb
111
        );
112
        $request = "<consSitMDFe xmlns=\"$this->urlPortal\" versao=\"$this->urlVersion\">"
113
            . "<tpAmb>$tpAmb</tpAmb>"
114
            . "<xServ>CONSULTAR</xServ>"
115
            . "<chMDFe>$chave</chMDFe>"
116
            . "</consSitMDFe>";
117
        $this->isValid($this->urlVersion, $request, 'consSitMDFe');
118
        $this->lastRequest = $request;
119
        $parameters = ['mdfeDadosMsg' => $request];
120
        $body = "<mdfeDadosMsg xmlns=\"$this->urlNamespace\">$request</mdfeDadosMsg>";
121
        $this->lastResponse = $this->sendRequest($body, $parameters);
122
        return $this->lastResponse;
123
    }
124
125
    /**
126
     * @author Cleiton Perin
@@ 132-156 (lines=25) @@
129
     * @param string $tpAmb tipo de ambiente 1-produção e 2-homologação
130
     * @return   mixed string XML do retorno do webservice, ou false se ocorreu algum erro
131
     */
132
    public function sefazStatus($uf = '', $tpAmb = null)
133
    {
134
        if (empty($tpAmb)) {
135
            $tpAmb = $this->tpAmb;
136
        }
137
        if (empty($uf)) {
138
            $uf = $this->config->siglaUF;
139
        }
140
        //carrega serviço
141
        $servico = 'MDFeStatusServico';
142
        $this->servico(
143
            $servico,
144
            $uf,
145
            $tpAmb
146
        );
147
        $request = "<consStatServMDFe xmlns=\"$this->urlPortal\" versao=\"$this->urlVersion\">"
148
            . "<tpAmb>$tpAmb</tpAmb>"
149
            . "<xServ>STATUS</xServ></consStatServMDFe>";
150
        $this->isValid($this->urlVersion, $request, 'consStatServMDFe');
151
        $this->lastRequest = $request;
152
        $parameters = ['mdfeDadosMsg' => $request];
153
        $body = "<mdfeDadosMsg xmlns=\"$this->urlNamespace\">$request</mdfeDadosMsg>";
154
        $this->lastResponse = $this->sendRequest($body, $parameters);
155
        return $this->lastResponse;
156
    }
157
158
    /**
159
     * @author Cleiton Perin