Completed
Pull Request — master (#175)
by Tom
05:04 queued 04:06
created

Strings   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A tokenize() 0 10 2
1
<?php
2
namespace Transphporm\Parser\Tokenizer;
3
use \Transphporm\Parser\Tokenizer;
4
use \Transphporm\Parser\Tokens;
5
6
class Strings implements \Transphporm\Parser\Tokenize {
7
8
	public function tokenize(TokenizedString $str, Tokens $tokens) {
9
		if ($str->identifyChar() === Tokenizer::STRING) {
10
			$chr = $str->read();
11
			$string = $str->extractString();
12
			$length = strlen($string)+1;
13
			$string = str_replace('\\' . $chr, $chr, $string);
14
			$tokens->add(['type' => Tokenizer::STRING, 'value' => $string, 'line' => $str->lineNo()]);
15
			$str->move($length);
16
		}
17
	}
18
19
}