AbstractEndpoint::call()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 6
cts 6
cp 1
rs 9.6666
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 2
crap 2
1
<?php
2
3
/*
4
 * This file is part of the AMFWebServicesClientBundle package.
5
 *
6
 * (c) Amine Fattouch <http://github.com/fattouchsquall>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace AMF\WebServicesClientBundle\Soap;
13
14
use AMF\WebServicesClientBundle\Soap\Security\Wsse;
15
16
/**
17
 * This class manages the interaction with a SOAP webservice.
18
 *
19
 * @author Mohamed Amine Fattouch <[email protected]>
20
 */
21
abstract class AbstractEndpoint
22
{
23
    /**
24
     * @var \SoapClient
25
     */
26
    protected $soapClient;
27
28
    /**
29
     * @var Wsse
30
     */
31
    protected $wsse;
32
33
    /**
34
     * @var boolean
35
     */
36
    protected $isSecure;
37
38
    /**
39
     * Constructor class.
40
     *
41
     * @param \SoapClient $soapClient The soap client.
42
     * @param Wsse        $wsse       The handler of soap wsse (default null).
43
     * @param boolean     $isSecure   Whether the webservice is secured or not (default false).
44
     */
45 3
    public function __construct(\SoapClient $soapClient, Wsse $wsse = null, $isSecure = false)
46
    {
47 3
        $this->soapClient = $soapClient;
48 3
        $this->wsse       = $wsse;
49 3
        $this->isSecure   = $isSecure;
50 3
    }
51
52
    /**
53
     * Calls web services with SoapClient.
54
     *
55
     * @param string $methodName The name of method to call.
56
     * @param array  $arguments  The arguments of the function to call (default empty).
57
     *
58
     * @return Soap response
59
     */
60 3
    public function call($methodName, array $arguments = [])
61
    {
62 3
        if ($this->isSecure === true) {
63 3
            $wsseHeader = $this->wsse->generateHeader();
64 3
            $this->soapClient->__setSoapHeaders($wsseHeader);
65 3
        }
66
67 3
        return $this->soapClient->__soapCall($methodName, $arguments);
68
    }
69
}
70