Completed
Push — master ( 491cb3...641a53 )
by Giancarlos
04:32
created

WSSESecurityHeader   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 19 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: Giansalex
5
 * Date: 15/07/2017
6
 * Time: 22:54
7
 */
8
9
namespace Greenter\Ws\Security;
10
11
use SoapHeader;
12
use SoapVar;
13
14
/**
15
 * Class WSSESecurityHeader
16
 * @package Greenter\Ws\Security
17
 */
18
class WSSESecurityHeader extends SoapHeader {
19
20 2
    public function __construct($username, $password)
21
    {
22 2
        $wsseNamespace = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd';
23 2
        $security = new SoapVar(
24 2
            array(new SoapVar(
25
                array(
26 2
                    new SoapVar($username, XSD_STRING, null, null, 'Username', $wsseNamespace),
27 2
                    new SoapVar($password, XSD_STRING, null, null, 'Password', $wsseNamespace)
28 2
                ),
29 2
                SOAP_ENC_OBJECT,
30 2
                null,
31 2
                null,
32 2
                'UsernameToken',
33
                $wsseNamespace
34 2
            )),
35
            SOAP_ENC_OBJECT
36 2
        );
37 2
        $this->SoapHeader($wsseNamespace, 'Security', $security, false);
38
    }
39
}