Completed
Push — master ( 62df29...4bf91f )
by Nicolas
02:57
created

InMemoryJson::getRoutingKeyFromHeader()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 5

Duplication

Lines 11
Ratio 100 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
dl 11
loc 11
ccs 6
cts 6
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 0
crap 2
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
        
36
    }
37
    
38 1 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 1
        $headers = $this->getHeaders();
41
        
42 1
        if(! array_key_exists('routing_key', $headers))
43 1
        {
44 1
            return null;
45
        }
46
        
47 1
        return $headers['routing_key'];
48
    }
49
}
50