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