Passed
Push — master ( 2944ee...dfe2d2 )
by Asmir
02:04
created

HeaderBag   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 52
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 52
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
declare(strict_types=1);
4
5
namespace GoetasWebservices\SoapServices\Metadata\Arguments\Headers;
6
7
class HeaderBag
8
{
9
    /**
10
     * @var object[]
11
     */
12
    private $headers = [];
13
    /**
14
     * @var object[]
15
     */
16
    private $mustUnderstandHeaders = [];
17
18
    public function __construct()
19
    {
20
    }
21
22
    public function hasHeader(object $header): bool
23
    {
24
        return isset($this->headers[spl_object_id($header)]);
25
    }
26
27
    public function addHeader(object $header): void
28
    {
29
        $this->headers[spl_object_id($header)] = $header;
30
    }
31
32
    public function getHeaders(): array
33
    {
34
        return $this->headers;
35
    }
36
37
    public function addMustUnderstandHeader(object $header): void
38
    {
39
        $this->mustUnderstandHeaders[spl_object_id($header)] = $header;
40
        $this->headers[spl_object_id($header)] = $header;
41
    }
42
43
    public function isMustUnderstandHeader(object $header): bool
44
    {
45
        return $this->hasHeader($header) && isset($this->mustUnderstandHeaders[spl_object_id($header)]);
46
    }
47
48
    public function removeMustUnderstandHeader(object $header): void
49
    {
50
        unset($this->mustUnderstandHeaders[spl_object_id($header)]);
51
    }
52
53
    /**
54
     * @return object[]
55
     */
56
    public function getMustUnderstandHeader(): array
57
    {
58
        return $this->mustUnderstandHeaders;
59
    }
60
}
61