Conditions | 3 |
Paths | 4 |
Total Lines | 26 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Tests | 14 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
14 | 7 | public function parse(string $html) : string |
|
15 | { |
||
16 | 7 | $html = ltrim($html); |
|
17 | |||
18 | // Get token position. |
||
19 | 7 | $positionArray = HtmlTokenizer::getPosition($html); |
|
20 | 7 | $this->line = $positionArray['line']; |
|
21 | 7 | $this->position = $positionArray['position']; |
|
22 | |||
23 | // Parse token. |
||
24 | 7 | $startPos = 3; |
|
25 | 7 | if (mb_substr(mb_strtolower($html), 0, 5) === '<?php') { |
|
26 | 7 | $startPos = 6; |
|
27 | } |
||
28 | |||
29 | 7 | $posOfEndOfPhp = mb_strpos($html, '?>'); |
|
30 | 7 | if ($posOfEndOfPhp === false) { |
|
31 | 1 | $this->value = trim(mb_substr($html, $startPos)); |
|
32 | |||
33 | 1 | return ''; |
|
34 | } |
||
35 | |||
36 | 6 | $this->value = trim(mb_substr($html, $startPos, $posOfEndOfPhp - $startPos - 1)); |
|
37 | |||
38 | 6 | return mb_substr($html, $posOfEndOfPhp + 2); |
|
39 | } |
||
40 | |||
51 |