Test Failed
Pull Request — master (#9)
by Nicolas
10:03 queued 04:15
created

Binary   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 43
c 0
b 0
f 0
wmc 7
lcom 1
cbo 0
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A format() 0 4 1
A footprint() 0 4 1
A changeContent() 0 4 1
A getContentType() 0 4 1
A __toString() 0 7 1
A decode() 0 4 1
1
<?php
2
3
namespace Puzzle\AMQP\Messages\Bodies;
4
5
use Puzzle\AMQP\Messages\Body;
6
use Puzzle\AMQP\Messages\ContentType;
7
8
class Binary implements Body
9
{
10
    private
11
        $body;
12
    
13
    public function __construct($content)
14
    {
15
        $this->changeContent($content);
16
    }
17
    
18
    public function format()
19
    {
20
        return $this->body;
21
    }
22
    
23
    public function footprint()
24
    {
25
        return uniqid(true);
26
    }
27
    
28
    public function changeContent($content)
29
    {
30
        $this->body = $content;
31
    }
32
    
33
    public function getContentType()
34
    {
35
        return ContentType::BINARY;
36
    }
37
    
38
    public function __toString()
39
    {
40
        return sprintf(
41
            '<binary stream of %d bytes>',
42
            strlen($this->body)
43
        );
44
    }
45
    
46
    public function decode()
47
    {
48
        return $this->body;
49
    }
50
}
51