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

SoapClient::call()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
crap 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
}