Completed
Pull Request — master (#7)
by Harry
02:53
created

Token::getContent()   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
 * This file is part of graze/csv-token
4
 *
5
 * Copyright (c) 2016 Nature Delivered Ltd. <https://www.graze.com>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @license https://github.com/graze/csv-token/blob/master/LICENSE.md
11
 * @link    https://github.com/graze/csv-token
12
 */
13
14
namespace Graze\CsvToken\Tokeniser\Token;
15
16
class Token
17
{
18
    const T_CONTENT      = 1;
19
    const T_DELIMITER    = 2;
20
    const T_NEW_LINE     = 4;
21
    const T_QUOTE        = 8;
22
    const T_NULL         = 16;
23
    const T_ESCAPE       = 32;
24
    const T_DOUBLE_QUOTE = 128;
25
    const T_BOM          = 256;
26
    const T_ANY          = 511;
27
28
    /** @var int */
29
    private $type;
30
    /** @var string */
31
    private $content;
32
    /** @var int */
33
    private $position;
34
    /** @var int */
35
    private $length;
36
37
    /**
38
     * Token constructor.
39
     *
40
     * @param int    $type
41
     * @param string $content
42
     * @param int    $position
43
     */
44 25
    public function __construct($type, $content, $position)
45
    {
46 25
        $this->type = $type;
47 25
        $this->content = $content;
48 25
        $this->length = strlen($content);
49 25
        $this->position = $position;
50 25
    }
51
52
    /**
53
     * @return int
54
     */
55 25
    public function getType()
56
    {
57 25
        return $this->type;
58
    }
59
60
    /**
61
     * @return string
62
     */
63 25
    public function getContent()
64
    {
65 25
        return $this->content;
66
    }
67
68
    /**
69
     * @return int
70
     */
71 25
    public function getLength()
72
    {
73 25
        return $this->length;
74
    }
75
76
    /**
77
     * @return int
78
     */
79 13
    public function getPosition()
80
    {
81 13
        return $this->position;
82
    }
83
84
    /**
85
     * Append some content onto this content
86
     *
87
     * @param string $content
88
     *
89
     * @return static
90
     */
91 24
    public function addContent($content)
92
    {
93 24
        $this->content .= $content;
94 24
        $this->length = strlen($this->content);
95 24
        return $this;
96
    }
97
}
98