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