Completed
Push — master ( a291fe...ff3596 )
by Giancarlos
02:48
created

BaseSunat::setService()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 0
cts 3
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
crap 2
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: Giansalex
5
 * Date: 15/07/2017
6
 * Time: 23:13
7
 */
8
9
namespace Greenter\Ws\Services;
10
11
use Greenter\Ws\Header\WSSESecurityHeader;
12
use SoapClient;
13
14
class BaseSunat
15
{
16
    /**
17
     * Url del servicio.
18
     * @var string
19
     */
20
    private $service;
21
22
    /**
23
     * Usuario (RUC + User SOL).
24
     * @var string
25
     */
26
    private $user;
27
    /**
28
     * Clave SOL
29
     *
30
     * @var string
31
     */
32
    private $password;
33
34
    /**
35
     * Parametros del Soap.
36
     * @var array
37
     */
38
    protected $parameters = [];
39
40
    /**
41
     * Url del WSDL.
42
     * @var string
43
     */
44
    protected $urlWsdl;
45
46
    /**
47
     * Set Credentiasl WebService.
48
     *
49
     * @param string $user
50
     * @param string $password
51
     */
52
    public function setCrentials($user, $password)
53
    {
54
        $this->user = $user;
55
        $this->password = $password;
56
    }
57
58
    /**
59
     * Create a new SoapClient.
60
     * @return SoapClient
61
     */
62
    public function getClient()
63
    {
64
        $client = new SoapClient($this->urlWsdl, $this->parameters);
65
        $client->__setLocation($this->service);
66
        $client->__setSoapHeaders(new WSSESecurityHeader($this->user, $this->password));
67
        return $client;
68
    }
69
70
    /**
71
     * Set Service of SUNAT.
72
     *
73
     * @param string $service
74
     * @return BaseSunat
75
     */
76
    public function setService($service)
77
    {
78
        $this->service = $service;
79
        return $this;
80
    }
81
82
    /**
83
     * Set Url del WSDL.
84
     *
85
     * @param string $urlWsdl
86
     * @return BaseSunat
87
     */
88
    public function setUrlWsdl($urlWsdl)
89
    {
90
        $this->urlWsdl = $urlWsdl;
91
        return $this;
92
    }
93
}