Passed
Pull Request — master (#7)
by Nicolas
02:59
created

InMemoryJson::getRawBody()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 0
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
    public function getDecodedBody()
17
    {
18
        return $this->body;
19
    }
20
    
21
    public function getAttributes()
22
    {
23
        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
        
36
    }
37
    
38 View Code Duplication
    public function getRoutingKeyFromHeader()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
39
    {
40
        $headers = $this->getHeaders();
41
        
42
        if(! array_key_exists('routing_key', $headers))
43
        {
44
            return null;
45
        }
46
        
47
        return $headers['routing_key'];
48
    }
49
}
50