Completed
Push — master ( d12968...2a6550 )
by Harry
02:36
created

Token::getLength()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Graze\CsvToken\Tokeniser;
4
5
class Token
6
{
7
    const T_CONTENT      = 1;
8
    const T_DELIMITER    = 2;
9
    const T_NEW_LINE     = 3;
10
    const T_QUOTE        = 4;
11
    const T_NULL         = 5;
12
    const T_ESCAPE       = 6;
13
    const T_DOUBLE_QUOTE = 7;
14
15
    /** @var int */
16
    private $type;
17
    /** @var string */
18
    private $content;
19
    /** @var int */
20
    private $position;
21
    /** @var int */
22
    private $length;
23
24
    /**
25
     * Token constructor.
26
     *
27
     * @param int    $type
28
     * @param string $content
29
     * @param int    $position
30
     */
31 13
    public function __construct($type, $content, $position)
32
    {
33 13
        $this->type = $type;
34 13
        $this->content = $content;
35 13
        $this->length = strlen($content);
36 13
        $this->position = $position;
37 13
    }
38
39
    /**
40
     * @return int
41
     */
42 13
    public function getType()
43
    {
44 13
        return $this->type;
45
    }
46
47
    /**
48
     * @return string
49
     */
50 13
    public function getContent()
51
    {
52 13
        return $this->content;
53
    }
54
55
    /**
56
     * @return int
57
     */
58 13
    public function getLength()
59
    {
60 13
        return $this->length;
61
    }
62
63
    /**
64
     * @return int
65
     */
66 5
    public function getPosition()
67
    {
68 5
        return $this->position;
69
    }
70
71
    /**
72
     * Append some content onto this content
73
     *
74
     * @param string $content
75
     *
76
     * @return static
77
     */
78 13
    public function addContent($content)
79
    {
80 13
        $this->content .= $content;
81 13
        $this->length = strlen($this->content);
82 13
        return $this;
83
    }
84
}
85