Completed
Pull Request — master (#175)
by Tom
02:04
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
/* @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
}