Completed
Pull Request — master (#9)
by Nicolas
03:04
created

InMemory::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
8
class InMemory extends Message implements ReadableMessage, WritableMessage
9
{
10 2
    public function getBody()
11
    {
12 2
        return $this->body;
13
    }
14
    
15
    public function getRawBody()
16
    {
17
        return $this->getFormattedBody();
18
    }
19
20
    public function getDecodedBody()
21
    {
22
        return $this->body->decode();
23
    }
24
25 2
    public function getAttributes()
26
    {
27 2
        return $this->packAttributes();
28
    }
29
30
    public function isLastRetry($retryOccurence = \Puzzle\AMQP\Consumers\Retry::DEFAULT_RETRY_OCCURENCE)
31
    {
32
        $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\InMemory. 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...
33
34
        return (!empty($retryHeader) && (int) $retryHeader === $retryOccurence);
35
    }
36
37 1
    public function getRoutingKeyFromHeader()
38
    {
39 1
        $headers = $this->getHeaders();
40
41 1
        if(! array_key_exists('routing_key', $headers))
42 1
        {
43 1
            return null;
44
        }
45
46 1
        return $headers['routing_key'];
47
    }
48
}
49