Completed
Pull Request — master (#175)
by Tom
02:04
created

Strings::tokenize()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 8
nc 2
nop 2
1
<?php
2
/* @description     Transformation Style Sheets - Revolutionising PHP templating    *
3
 * @author          Tom Butler [email protected]                                             *
4
 * @copyright       2017 Tom Butler <[email protected]> | https://r.je/                      *
5
 * @license         http://www.opensource.org/licenses/bsd-license.php  BSD License *
6
 * @version         1.2                                                             */
7
 namespace Transphporm\Parser\Tokenizer;
8
use \Transphporm\Parser\Tokenizer;
9
use \Transphporm\Parser\Tokens;
10
11
class Strings implements \Transphporm\Parser\Tokenize {
12
13
	public function tokenize(TokenizedString $str, Tokens $tokens) {
14
		if ($str->identifyChar() === Tokenizer::STRING) {
15
			$chr = $str->read();
16
			$string = $str->extractString();
17
			$length = strlen($string)+1;
18
			$string = str_replace('\\' . $chr, $chr, $string);
19
			$tokens->add(['type' => Tokenizer::STRING, 'value' => $string, 'line' => $str->lineNo()]);
20
			$str->move($length);
21
		}
22
	}
23
24
}