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

Token   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 80
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 6
c 2
b 1
f 0
lcom 1
cbo 0
dl 0
loc 80
ccs 18
cts 18
cp 1
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A getType() 0 4 1
A getContent() 0 4 1
A getLength() 0 4 1
A getPosition() 0 4 1
A addContent() 0 6 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