Passed
Pull Request — master (#6)
by Daniel
02:58
created

Message::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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
     * @param string $key
24
     *
25
     * @return string|null
26
     */
27
    public function getHeader(string $key): ?string
28
    {
29
        if (!\array_key_exists($key, $this->headers)) {
30
            return null;
31
        }
32
33
        return $this->headers[$key];
34
    }
35
36
    /**
37
     * @param string $key
38
     * @param string $value
39
     *
40
     * @return \Jellyfish\Queue\MessageInterface
41
     */
42
    public function setHeader(string $key, string $value): MessageInterface
43
    {
44
        $this->headers[$key] = $value;
45
46
        return $this;
47
    }
48
49
    /**
50
     * @return string
51
     */
52
    public function getBody(): string
53
    {
54
        return $this->body;
55
    }
56
57
    /**
58
     * @param string $body
59
     *
60
     * @return \Jellyfish\Queue\MessageInterface
61
     */
62
    public function setBody(string $body): MessageInterface
63
    {
64
        $this->body = $body;
65
66
        return $this;
67
    }
68
}
69