Completed
Push — master ( 4bf91f...d42076 )
by Nicolas
03:14
created

InMemoryJson::getAttributes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Puzzle\AMQP\Messages;
4
5
use Puzzle\AMQP\ReadableMessage;
6
use Puzzle\AMQP\WritableMessage;
7
use Puzzle\AMQP\Collections\MessageHookCollection;
8
9
class InMemoryJson extends Json implements ReadableMessage, WritableMessage
10
{
11
    public function getRawBody()
12
    {
13
        return $this->getFormattedBody();
14
    }
15
16 2
    public function getDecodedBody()
17
    {
18 2
        return $this->body;
19
    }
20
21 2
    public function getAttributes()
22
    {
23 2
        return $this->packAttributes();
24
    }
25
26
    public function isLastRetry($retryOccurence = \Puzzle\AMQP\Consumers\Retry::DEFAULT_RETRY_OCCURENCE)
27
    {
28
        $retryHeader = $this->getHeader(\Puzzle\AMQP\Consumers\Retry::DEFAULT_RETRY_HEADER);
0 ignored issues
show
Bug introduced by
The method getHeader() does not exist on Puzzle\AMQP\Messages\InMemoryJson. Did you maybe mean getHeaders()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
29
30
        return (!empty($retryHeader) && (int) $retryHeader === $retryOccurence);
31
    }
32
33
    public function applyHooks(MessageHookCollection $messageHookCollection)
34
    {
35
        $body = $this->body;
36
37
        foreach($messageHookCollection as $hook)
38
        {
39
            $body = $hook->process($body);
40
        }
41
42
        $this->body = $body;
43
    }
44
45 1
    public function getRoutingKeyFromHeader()
46
    {
47 1
        $headers = $this->getHeaders();
48
49 1
        if(! array_key_exists('routing_key', $headers))
50 1
        {
51 1
            return null;
52
        }
53
54 1
        return $headers['routing_key'];
55
    }
56
}
57