Completed
Push — master ( f338a0...491cb3 )
by Giancarlos
02:24
created

BaseSunat   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 79
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 66.67%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 79
ccs 10
cts 15
cp 0.6667
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getClient() 0 7 1
A setService() 0 5 1
A setUrlWsdl() 0 5 1
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
12
use Greenter\Ws\Security\WSSESecurityHeader;
13
use SoapClient;
14
15
class BaseSunat
16
{
17
    /**
18
     * Url del servicio.
19
     * @var string
20
     */
21
    private $service;
22
23
    /**
24
     * Usuario (RUC + User SOL).
25
     * @var string
26
     */
27
    private $user;
28
    /**
29
     * Clave SOL
30
     *
31
     * @var string
32
     */
33
    private $password;
34
35
    /**
36
     * Parametros del Soap.
37
     * @var array
38
     */
39
    protected $parameters = [];
40
41
    /**
42
     * Url del WSDL.
43
     * @var string
44
     */
45
    protected $urlWsdl;
46
47
    /**
48
     * BaseSunat constructor.
49
     * @param string $user
50
     * @param string $password
51
     */
52 2
    public function __construct($user, $password)
53
    {
54 2
        $this->user = $user;
55 2
        $this->password = $password;
56 2
    }
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 2
    public function setService($service)
77
    {
78 2
        $this->service = $service;
79 2
        return $this;
80
    }
81
82
    /**
83
     * Set Url del WSDL.
84
     *
85
     * @param string $urlWsdl
86
     * @return BaseSunat
87
     */
88 2
    public function setUrlWsdl($urlWsdl)
89
    {
90 2
        $this->urlWsdl = $urlWsdl;
91 2
        return $this;
92
    }
93
}