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

Binary::__toString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
crap 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;
1 ignored issue
show
Coding Style introduced by
The visibility should be declared for property $body.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
12
    
13 1
    public function __construct($content)
14
    {
15 1
        $this->changeContent($content);
16 1
    }
17
    
18
    public function format()
19
    {
20
        return $this->body;
21
    }
22
    
23
    public function footprint()
24
    {
25
        return uniqid(true);
26
    }
27
    
28 1
    public function changeContent($content)
29
    {
30 1
        $this->body = $content;
31 1
    }
32
    
33 1
    public function getContentType()
34
    {
35 1
        return ContentType::BINARY;
36
    }
37
    
38 1
    public function __toString()
39
    {
40 1
        return sprintf(
41 1
            '<binary stream of %d bytes>',
42 1
            strlen($this->body)
43 1
        );
44
    }
45
    
46
    public function decode()
47
    {
48
        return $this->body;
49
    }
50
}
51