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

InMemory   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 58.81%

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 2
dl 0
loc 41
ccs 10
cts 17
cp 0.5881
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getBody() 0 4 1
A getRawBody() 0 4 1
A getDecodedBody() 0 4 1
A getAttributes() 0 4 1
A isLastRetry() 0 6 2
A getRoutingKeyFromHeader() 0 11 2
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