Completed
Pull Request — master (#6)
by Daniel
02:44
created

Message::setHeader()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
namespace Jellyfish\Queue;
4
5
class Message implements MessageInterface
6
{
7
    /**
8
     * @var array
9
     */
10
    protected $headers;
11
12
    /**
13
     * @var string
14
     */
15
    protected $body;
16
17
    public function __construct()
18
    {
19
        $this->headers = [];
20
    }
21
22
    /**
23
     * @return array
24
     */
25
    public function getHeaders(): array
26
    {
27
        return $this->headers;
28
    }
29
30
    /**
31
     * @param array $headers
32
     *
33
     * @return \Jellyfish\Queue\MessageInterface
34
     */
35
    public function setHeaders(array $headers): MessageInterface
36
    {
37
        $this->headers = $headers;
38
39
        return $this;
40
    }
41
42
    /**
43
     * @param string $key
44
     *
45
     * @return string|null
46
     */
47
    public function getHeader(string $key): ?string
48
    {
49
        if (!\array_key_exists($key, $this->headers)) {
50
            return null;
51
        }
52
53
        return $this->headers[$key];
54
    }
55
56
    /**
57
     * @param string $key
58
     * @param string $value
59
     *
60
     * @return \Jellyfish\Queue\MessageInterface
61
     */
62
    public function setHeader(string $key, string $value): MessageInterface
63
    {
64
        $this->headers[$key] = $value;
65
66
        return $this;
67
    }
68
69
    /**
70
     * @return string
71
     */
72
    public function getBody(): string
73
    {
74
        return $this->body;
75
    }
76
77
    /**
78
     * @param string $body
79
     *
80
     * @return \Jellyfish\Queue\MessageInterface
81
     */
82
    public function setBody(string $body): MessageInterface
83
    {
84
        $this->body = $body;
85
86
        return $this;
87
    }
88
}
89