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

Text::append()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
c 0
b 0
f 0
rs 9.4285
cc 2
eloc 5
nc 2
nop 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 Text implements Body
9
{
10
    private
11
        $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...
12
    
13
    public function __construct($text)
14
    {
15
        $this->changeText($text);
16
    }
17
    
18
    public function format()
19
    {
20
        return implode("\n", $this->content);
21
    }
22
    
23
    public function footprint()
24
    {
25
        return sha1($this->format());
26
    }
27
    
28
    public function changeText($text)
29
    {
30
        if(! is_array($text))
31
        {
32
            $text = array($text);
33
        }
34
        
35
        $this->content = $text;
36
    }
37
    
38
    public function append($text)
39
    {
40
        if(is_array($text))
41
        {
42
            $this->content = array_merge($this->content, $text);
43
            
44
            return;
45
        }
46
        
47
        $this->content[] = $text;
48
    }
49
50
    public function getContentType()
51
    {
52
        return ContentType::TEXT;
53
    }
54
    
55
    public function __toString()
56
    {
57
        return $this->format();
58
    }
59
    
60
    public function decode()
61
    {
62
        return $this->format();
63
    }
64
}
65