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

HeaderBag::removeMustUnderstandHeader()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 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