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