Test Failed
Pull Request — master (#9)
by Nicolas
03:34
created

Text::format()   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\Bodies;
4
5
use Puzzle\AMQP\Messages\Body;
6
use Puzzle\AMQP\Messages\ContentType;
7
use Puzzle\AMQP\Messages\Footprintable;
8
9
class Text implements Body, Footprintable
10
{
11
    private
12
        $content;
1 ignored issue
show
Coding Style introduced by
The visibility should be declared for property $content.

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...
13
    
14
    public function __construct($text)
15
    {
16
        $this->changeText($text);
17
    }
18
    
19
    public function format()
20
    {
21
        return implode("\n", $this->content);
22
    }
23
    
24
    public function footprint()
25
    {
26
        return sha1($this->format());
27
    }
28
    
29
    public function changeText($text)
30
    {
31
        if(! is_array($text))
32
        {
33
            $text = array($text);
34
        }
35
        
36
        $this->content = $text;
37
    }
38
    
39
    public function append($text)
40
    {
41
        if(is_array($text))
42
        {
43
            $this->content = array_merge($this->content, $text);
44
            
45
            return;
46
        }
47
        
48
        $this->content[] = $text;
49
    }
50
51
    public function getContentType()
52
    {
53
        return ContentType::TEXT;
54
    }
55
    
56
    public function __toString()
57
    {
58
        return $this->format();
59
    }
60
    
61
    public function decode()
62
    {
63
        return $this->format();
64
    }
65
}
66