Passed
Push — ref ( 45b89b )
by Asmir
02:50
created

HeaderBag::addMustUnderstandHeader()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace GoetasWebservices\SoapServices\Metadata\Arguments\Headers;
4
5
class HeaderBag
6
{
7
    private $headers = [];
8
    private $mustUnderstandHeaders = [];
9
    public function __construct()
10
    {
11
12
    }
13
14
    public function hasHeader(object $header):bool
15
    {
16
        return isset($this->headers[spl_object_id($header)]);
17
    }
18
19
    public function addHeader(object $header):void
20
    {
21
        $this->headers[spl_object_id($header)] = $header;
22
    }
23
24
    public function getHeaders():array
25
    {
26
        return $this->headers;
27
    }
28
29
    public function addMustUnderstandHeader(object $header):void
30
    {
31
        $this->mustUnderstandHeaders[spl_object_id($header)] = $header;
32
        $this->headers[spl_object_id($header)] = $header;
33
    }
34
35
    public function isMustUnderstandHeader(object $header):bool
36
    {
37
        return $this->hasHeader($header) && isset($this->mustUnderstandHeaders[spl_object_id($header)]);
38
    }
39
40
    public function removeMustUnderstandHeader(object $header):void
41
    {
42
        unset($this->mustUnderstandHeaders[spl_object_id($header)]);
43
    }
44
45
    /**
46
     * @return object[]
47
     */
48
    public function getMustUnderstandHeader(): array
49
    {
50
        return $this->mustUnderstandHeaders;
51
    }
52
}
53