Completed
Pull Request — master (#41)
by Lars
03:14
created

KeepOriginalValueLexer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 16
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getNextToken() 0 13 2
1
<?php
2
3
namespace Spatie\Php7to5\PhpParser;
4
5
use PhpParser\Lexer;
6
use PhpParser\Parser\Tokens;
7
8
class KeepOriginalValueLexer extends Lexer // or Lexer\Emulative
9
{
10
    public function getNextToken(&$value = null, &$startAttributes = null, &$endAttributes = null): int
11
    {
12
        $tokenId = parent::getNextToken($value, $startAttributes, $endAttributes);
13
14
        // DEBUG
15
        //var_dump($tokenId, $value);
16
17
        if ($tokenId == Tokens::T_CONSTANT_ENCAPSED_STRING) {
18
            $endAttributes['originalValue'] = '_+*-7-to-5-*+_' . $value . '_+*-7-to-5-*+_';
19
        }
20
21
        return $tokenId;
22
    }
23
}
24