Passed
Push — develop ( e10991...f36a80 )
by Mikaël
04:03
created

Security::__toSend()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 7
ccs 6
cts 6
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace WsdlToPhp\WsSecurity;
4
5
class Security extends Element
6
{
7
    /**
8
     * Element name
9
     * @var string
10
     */
11
    const NAME = 'Security';
12
    /**
13
     * Element attribute mustunderstand name
14
     * @var string
15
     */
16
    const ATTRIBUTE_MUST_UNDERSTAND = ':mustunderstand';
17
    /**
18
     * Element attribute mustunderstand name
19
     * @var string
20
     */
21
    const ATTRIBUTE_ACTOR = ':actor';
22
    /**
23
     * Envelop namespace
24
     * @var string
25
     */
26
    const ENV_NAMESPACE = 'SOAP-ENV';
27
    /**
28
     * UsernameToken element
29
     * @var UsernameToken
30
     */
31
    protected $usernameToken;
32
    /**
33
     * Timestamp element
34
     * @var Timestamp
35
     */
36
    protected $timestamp;
37
38
    /**
39
     * Constructor for Nonce element
40
     *
41
     * @param bool   $mustunderstand
42
     * @param string $actor
43
     * @param string $envelopeNamespace
44
     * @param string $namespace the namespace
45
     */
46 54
    public function __construct($mustunderstand = false, $actor = null, $namespace = self::NS_WSSE, $envelopeNamespace = self::ENV_NAMESPACE)
47
    {
48 54
        parent::__construct(self::NAME, $namespace);
49
        /**
50
         * Sets attributes
51
         */
52 54
        if ($mustunderstand === true) {
53 42
            $this->setAttribute($envelopeNamespace. self::ATTRIBUTE_MUST_UNDERSTAND, $mustunderstand);
54 21
        }
55 54
        if (!empty($actor)) {
56 36
            $this->setAttribute($envelopeNamespace . self::ATTRIBUTE_ACTOR, $actor);
57 18
        }
58 54
    }
59
    /**
60
     * @return UsernameToken
61
     */
62 54
    public function getUsernameToken()
63
    {
64 54
        return $this->usernameToken;
65
    }
66
    /**
67
     * @param UsernameToken $usernameToken
68
     * @return Security
69
     */
70 54
    public function setUsernameToken(UsernameToken $usernameToken)
71
    {
72 54
        $this->usernameToken = $usernameToken;
73 54
        return $this;
74
    }
75
    /**
76
     * @return Timestamp
77
     */
78 54
    public function getTimestamp()
79
    {
80 54
        return $this->timestamp;
81
    }
82
    /**
83
     * @param Timestamp $timestamp
84
     * @return Security
85
     */
86 6
    public function setTimestamp(Timestamp $timestamp)
87
    {
88 6
        $this->timestamp = $timestamp;
89 6
        return $this;
90
    }
91
    /**
92
     * Overrides methods in order to set the values
93
     * @param bool $asDomElement returns elements as a DOMElement or as a string
94
     * @return string
95
     */
96 54
    protected function __toSend($asDomElement = false)
97
    {
98 54
        $this->setValue([
99 54
            $this->getUsernameToken(),
100 54
            $this->getTimestamp(),
101 27
        ]);
102 54
        return parent::__toSend($asDomElement);
0 ignored issues
show
Bug Best Practice introduced by
The expression return parent::__toSend($asDomElement) also could return the type DOMElement which is incompatible with the documented return type string.
Loading history...
103
    }
104
}
105