Passed
Push — master ( 1c3add...f7b615 )
by Giancarlos
02:50
created

SoapClient   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 85.71%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 46
ccs 12
cts 14
cp 0.8571
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 2
A setCredentials() 0 4 1
A setService() 0 4 1
A call() 0 4 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: Administrador
5
 * Date: 03/10/2017
6
 * Time: 09:47 AM
7
 */
8
9
namespace Greenter\Ws\Services;
10
11
use Greenter\Ws\Header\WSSESecurityHeader;
12
13
/**
14
 * Class SoapClient
15
 * @package Greenter\Ws\Services
16
 */
17
class SoapClient implements WsClientInterface
18
{
19
    private $client;
20
21
    /**
22
     * SoapClient constructor.
23
     * @param string $wsdl          Url of WSDL
24
     * @param array $parameters     Soap's parameters
25
     */
26 50
    public function __construct($wsdl = '', $parameters = [])
27
    {
28 50
        if (empty($wsdl)) {
29
            $wsdl = __DIR__.'/../../Resources/wsdl/billService.wsdl';
30
        }
31 50
        $this->client = new \SoapClient($wsdl, $parameters);
32 50
    }
33
34
    /**
35
     * @param $user
36
     * @param $password
37
     */
38 50
    public function setCredentials($user, $password)
39
    {
40 50
        $this->client->__setSoapHeaders(new WSSESecurityHeader($user, $password));
41 50
    }
42
43
    /**
44
     * Set Url of Service.
45
     *
46
     * @param string $url
47
     */
48 50
    public function setService($url)
49
    {
50 50
        $this->client->__setLocation($url);
51 50
    }
52
53
    /**
54
     * @param $function
55
     * @param $arguments
56
     * @return mixed
57
     */
58 32
    public function call($function, $arguments)
59
    {
60 32
        return $this->client->__soapCall($function, $arguments);
61
    }
62
}