InvoiceOneStrategy::makeRequest()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the cfdi-certificate project.
5
 *
6
 * (c) Kinedu
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Kinedu\CfdiPac\Strategies;
13
14
use SoapClient;
15
use Kinedu\CfdiPac\PACSoapRequest;
16
17
class InvoiceOneStrategy extends PACSoapRequest
18
{
19
    /**
20
     * Invoice one endpoint
21
     *
22
     * @var string
23
     */
24
    const WSDL_ENDPOINT = 'https://invoiceone.mx/TimbreCFDI/timbrecfdi.asmx?WSDL';
25
26
    /**
27
     * Invoice One Soap request.
28
     *
29
     * @return stdClass
30
     */
31
    protected function makeRequest()
32
    {
33
        $client = new SoapClient(static::WSDL_ENDPOINT, $this->options);
34
35
        return $client->{$this->getMethodName()}([
36
            'usuario' => $this->username,
37
            'contrasena' => $this->password,
38
            'xmlComprobante' => $this->xml,
39
        ]);
40
    }
41
42
    /**
43
     * Returns the cfdi with the TFD node.
44
     *
45
     * @return string
46
     */
47
    public function getXML(): string
48
    {
49
        $request = $this->makeRequest();
50
51
        $resultName = $this->getMethodName().'Result';
52
53
        return $request->{$resultName}->Xml;
54
    }
55
56
    /**
57
     * Soap method name.
58
     *
59
     * @return string
60
     */
61
    protected function getMethodName(): string
62
    {
63
        return ($this->test) ? 'ObtenerCFDIPrueba' : 'ObtenerCFDI';
64
    }
65
}
66