Lexer::getNextToken()   A
last analyzed

Complexity

Conditions 4
Paths 8

Size

Total Lines 18
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 1 Features 0
Metric Value
c 3
b 1
f 0
dl 0
loc 18
rs 9.2
cc 4
eloc 9
nc 8
nop 3
1
<?php
2
3
namespace PhpSchool\PSX;
4
5
use PhpParser\Lexer\Emulative;
6
use PhpParser\Parser\Tokens;
7
8
/**
9
 * Class Lexer
10
 * @package PhpSchool\PSX
11
 * @author Aydin Hassan <[email protected]>
12
 */
13
class Lexer extends Emulative
14
{
15
    public function getNextToken(&$value = null, &$startAttributes = null, &$endAttributes = null)
16
    {
17
        $tokenId = parent::getNextToken($value, $startAttributes, $endAttributes);
18
19
        if ($tokenId == Tokens::T_ARRAY) {
20
            $startAttributes['traditionalArray'] = true;
21
        }
22
23
        if ($tokenId == Tokens::T_EXIT) {
24
            $startAttributes['isDie'] = strtolower($value) === 'die';
25
        }
26
27
        if ($tokenId == Tokens::T_CONSTANT_ENCAPSED_STRING) {
28
            $endAttributes['originalValue'] = $value;
29
        }
30
        
31
        return $tokenId;
32
    }
33
}
34