Completed
Pull Request — master (#9)
by Nicolas
02:51
created

Binary   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 88.24%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 34
ccs 15
cts 17
cp 0.8824
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A initBody() 0 4 1
A formatBody() 0 4 1
A setBody() 0 6 1
A getContentType() 0 4 1
A __toString() 0 9 1
1
<?php
2
3
namespace Puzzle\AMQP\Messages;
4
5
use Puzzle\AMQP\WritableMessage;
6
7
class Binary extends Raw implements WritableMessage
8
{
9 1
    protected function initBody()
10
    {
11 1
        $this->body = null;
12 1
    }
13
    
14
    protected function formatBody()
15
    {
16
        return $this->body;
17
    }
18
    
19 1
    public function setBody($body)
20
    {
21 1
        $this->body = $body;
22
    
23 1
        return $this;
24
    }
25
    
26 1
    public function getContentType()
27
    {
28 1
        return ContentType::BINARY;
29
    }
30
    
31 1
    public function __toString()
32
    {
33 1
        return json_encode(array(
34 1
            'routing_key' => $this->getRoutingKey(),
35 1
            'body' => sprintf('<binary stream of %d bytes>', strlen($this->body)),
36 1
            'attributes' => $this->attributes,
0 ignored issues
show
Bug introduced by
The property attributes cannot be accessed from this context as it is declared private in class Puzzle\AMQP\Messages\Raw.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
37 1
            'flags' => $this->flags
0 ignored issues
show
Bug introduced by
The property flags cannot be accessed from this context as it is declared private in class Puzzle\AMQP\Messages\Raw.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
38 1
        ));
39
    }
40
}
41