Completed
Push — master ( e40fed...ed70fa )
by Portey
02:55
created

Token::toString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 3
Bugs 1 Features 0
Metric Value
c 3
b 1
f 0
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * Date: 23.11.15
4
 *
5
 * @author Portey Vasil <[email protected]>
6
 */
7
8
namespace Youshido\GraphQL\Parser;
9
10
class Token
11
{
12
13
    const TYPE_END        = 'end';
14
    const TYPE_IDENTIFIER = 'identifier';
15
    const TYPE_NUMBER     = 'number';
16
    const TYPE_STRING     = 'string';
17
    const TYPE_ON         = 'on';
18
19
    const TYPE_QUERY              = 'query';
20
    const TYPE_MUTATION           = 'mutation';
21
    const TYPE_FRAGMENT           = 'fragment';
22
    const TYPE_FRAGMENT_REFERENCE = '...';
23
24
    const TYPE_LT            = '<';
25
    const TYPE_GT            = '>';
26
    const TYPE_LBRACE        = '{';
27
    const TYPE_RBRACE        = '}';
28
    const TYPE_LPAREN        = '(';
29
    const TYPE_RPAREN        = ')';
30
    const TYPE_LSQUARE_BRACE = '[';
31
    const TYPE_RSQUARE_BRACE = ']';
32
    const TYPE_COLON         = ':';
33
    const TYPE_COMMA         = ',';
34
    const TYPE_AMP           = '&';
35
    const TYPE_VARIABLE      = '$';
36
    const TYPE_POINT         = '.';
37
38
    const TYPE_NULL  = 'null';
39
    const TYPE_TRUE  = 'true';
40
    const TYPE_FALSE = 'false';
41
42
43
    /** @var mixed */
44
    private $data;
45
    /** @var  string */
46
    private $type;
47
    /** @var int */
48
    private $line;
49
    /** @var int */
50
    private $column;
51
52 26
    public function __construct($type, $data = null)
53
    {
54 26
        $this->type = $type;
55 26
        $this->data = $data;
56
57 26
        if ($this->getType() == self::TYPE_TRUE) {
58 2
            $this->data = true;
59 2
        }
60
61 26
        if ($this->getType() == self::TYPE_FALSE) {
62 1
            $this->data = false;
63 1
        }
64
65 26
        if ($this->getType() == self::TYPE_NULL) {
66 2
            $this->data = null;
67 2
        }
68
69 26
    }
70
71
    /**
72
     * @return mixed
73
     */
74 24
    public function getData()
75
    {
76 24
        return $this->data;
77
    }
78
79
    /**
80
     * @return string
81
     */
82 26
    public function getType()
83
    {
84 26
        return $this->type;
85
    }
86
87
    /**
88
     * @param int $line
89
     */
90 26
    public function setLine($line)
91
    {
92 26
        $this->line = $line;
93 26
    }
94
95
    /**
96
     * @param int $column
97
     */
98 26
    public function setColumn($column)
99
    {
100 26
        $this->column = $column;
101 26
    }
102
103
}