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

WSSESecurityHeader::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 15
CRAP Score 1

Importance

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