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

HeaderBag   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 9
eloc 11
c 1
b 0
f 0
dl 0
loc 46
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A addMustUnderstandHeader() 0 4 1
A hasHeader() 0 3 1
A removeMustUnderstandHeader() 0 3 1
A isMustUnderstandHeader() 0 3 2
A getMustUnderstandHeader() 0 3 1
A addHeader() 0 3 1
A __construct() 0 2 1
A getHeaders() 0 3 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