Code

< 40 %
40-60 %
> 60 %
1
<?php
2
3
namespace CfdiUtils\ConsultaCfdiSat;
4
5
class Config
6
{
7
    /**
8
     * Default value of SAT web service
9
     * @var string
10
     */
11
    public const DEFAULT_SERVICE_URL = 'https://consultaqr.facturaelectronica.sat.gob.mx/ConsultaCFDIService.svc';
12
13
    /**
14
     * This library does not use WSDL anymore
15
     *
16
     * @deprecated :3.0.0
17
     * @see self::DEFAULT_SERVICE_URL
18
     * @var string
19
     */
20
    public const DEFAULT_WSDL_URL = self::DEFAULT_SERVICE_URL . '?singleWsdl';
21
22
    /** @var int */
23
    private $timeout;
24
25
    /** @var bool */
26
    private $verifyPeer;
27
28
    /** @var string */
29
    private $serviceUrl;
30
31
    /** @var string */
32
    private $wsdlLocation;
33
34 13
    public function __construct(
35
        int $timeout = 10,
36
        bool $verifyPeer = true,
37
        string $serviceUrl = '',
38
        string $wsdlLocation = ''
39
    ) {
40 13
        $this->timeout = $timeout;
41 13
        $this->verifyPeer = $verifyPeer;
42 13
        $this->serviceUrl = $serviceUrl ?: static::DEFAULT_SERVICE_URL;
43 13
        $this->wsdlLocation = $wsdlLocation;
44 13
        if ('' !== $this->wsdlLocation) {
45
            trigger_error(__CLASS__ . ' deprecated WSDL location', E_USER_DEPRECATED);
46
        }
47
    }
48
49 7
    public function getTimeout(): int
50
    {
51 7
        return $this->timeout;
52
    }
53
54 7
    public function shouldVerifyPeer(): bool
55
    {
56 7
        return $this->verifyPeer;
57
    }
58
59
    /**
60
     * @deprecated since Version 2.7.1 in favor of getServiceUrl
61
     * @see getServiceUrl
62
     * @return string
63
     */
64
    public function getWsdlUrl(): string
65
    {
66
        return $this->getServiceUrl();
67
    }
68
69 7
    public function getServiceUrl(): string
70
    {
71 7
        return $this->serviceUrl;
72
    }
73
74
    /**
75
     * @deprecated 2.10.0:3.0.0 WebService does not require WSDL anymore
76
     * @return string
77
     */
78
    public function getWsdlLocation(): string
79
    {
80
        trigger_error(__METHOD__ . ' is deprecated since WebService does not require WSDL anymore', E_USER_DEPRECATED);
81
        return $this->wsdlLocation;
82
    }
83
84
    /**
85
     * @deprecated 2.10.0:3.0.0 Service does not require WSDL anymore
86
     * @return string
87
     */
88
    public static function getLocalWsdlLocation(): string
89
    {
90
        trigger_error(__METHOD__ . ' is deprecated since WebService does not require WSDL anymore', E_USER_DEPRECATED);
91
        return __DIR__ . DIRECTORY_SEPARATOR . 'ConsultaCFDIServiceSAT.svc.xml';
92
    }
93
}
94