Completed
Push — feature/issue-7 ( 9d75a7...1ff64b )
by Mikaël
03:36
created

Timestamp   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 86
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
eloc 15
dl 0
loc 86
ccs 19
cts 19
cp 1
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A setCreated() 0 5 1
A __construct() 0 3 1
A getExpires() 0 3 1
A __toSend() 0 8 1
A setExpires() 0 5 1
A getCreated() 0 3 1
1
<?php
2
3
namespace WsdlToPhp\WsSecurity;
4
5
class Timestamp extends Element
6
{
7
    /**
8
     * Element name.
9
     *
10
     * @var string
11
     */
12
    const NAME = 'Timestamp';
13
    /**
14
     * Created element.
15
     *
16
     * @var Created
17
     */
18
    protected $created;
19
    /**
20
     * Created element.
21
     *
22
     * @var Expires
23
     */
24
    protected $expires;
25
26
    /**
27
     * Constructor for Timestamp element.
28
     *
29
     * @param string $namespace the namespace
30
     */
31 6
    public function __construct($namespace = self::NS_WSSU)
32
    {
33 6
        parent::__construct(self::NAME, $namespace);
34 6
    }
35
36
    /**
37
     * Overrides method in order to add created and expires values if they are set.
38
     *
39
     * @param bool $asDomElement returns elements as a DOMElement or as a string
40
     *
41
     * @return string
42
     */
43 6
    protected function __toSend($asDomElement = false)
44
    {
45 6
        $this->setValue([
46 6
            $this->getCreated(),
47 6
            $this->getExpires(),
48 3
        ]);
49
50 6
        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...
51
    }
52
53
    /**
54
     * @return Created
55
     */
56 6
    public function getCreated()
57
    {
58 6
        return $this->created;
59
    }
60
61
    /**
62
     * @param Created $created
63
     *
64
     * @return Timestamp
65
     */
66 6
    public function setCreated(Created $created)
67
    {
68 6
        $this->created = $created;
69
70 6
        return $this;
71
    }
72
73
    /**
74
     * @return Expires
75
     */
76 6
    public function getExpires()
77
    {
78 6
        return $this->expires;
79
    }
80
81
    /**
82
     * @param Expires $expires
83
     *
84
     * @return Expires
85
     */
86 6
    public function setExpires(Expires $expires)
87
    {
88 6
        $this->expires = $expires;
89
90 6
        return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type WsdlToPhp\WsSecurity\Timestamp which is incompatible with the documented return type WsdlToPhp\WsSecurity\Expires.
Loading history...
91
    }
92
}
93