Completed
Push — master ( 4ad1fe...6fedad )
by Basil
13:41 queued 04:49
created

TextValue::encode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace luya\web\jsonld;
4
5
use luya\helpers\StringHelper;
6
use luya\helpers\Html;
7
8
/**
9
 * Text Value.
10
 *
11
 * The text value provides option to auto shorten content.
12
 *
13
 * @author Basil Suter <[email protected]>
14
 * @since 1.0.3
15
 */
16
class TextValue extends BaseValue
17
{
18
    private $_text;
19
    
20
    /**
21
     * Provide date data.
22
     *
23
     * @param string|integer $date
0 ignored issues
show
Bug introduced by
There is no parameter named $date. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
24
     */
25
    public function __construct($text)
26
    {
27
        $this->_text = $text;
28
    }
29
    
30
    /**
31
     * Truncate the string for a given lenth.
32
     *
33
     * @param integer $length
34
     * @return \luya\web\jsonld\TextValue
35
     */
36
    public function truncate($length)
37
    {
38
        $this->_text = StringHelper::truncate($this->_text, $length);
39
        
40
        return $this;
41
    }
42
    
43
    /**
44
     * Html encode the text data.
45
     * 
46
     * @return \luya\web\jsonld\TextValue
47
     */
48
    public function encode()
49
    {
50
        $this->_text = Html::encode($this->_text);
51
        
52
        return $this;
53
    }
54
    
55
    /**
56
     * @inheritDoc
57
     */
58
    public function getValue()
59
    {
60
        return $this->_text;
61
    }
62
}
63