Conditions | 3 |
Paths | 3 |
Total Lines | 19 |
Code Lines | 10 |
Lines | 19 |
Ratio | 100 % |
Tests | 10 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
14 | 8 | public function parse(string $html) : string |
|
15 | { |
||
16 | 8 | $html = ltrim($html); |
|
17 | 8 | $this->setTokenPosition($html); |
|
18 | |||
19 | // Parse token. |
||
20 | 8 | $posOfEndOfDocType = mb_strpos($html, '>'); |
|
21 | 8 | if ($posOfEndOfDocType === false) { |
|
22 | 2 | if ($this->getThrowOnError()) { |
|
23 | 1 | throw new ParseException('Invalid DOCTYPE.'); |
|
24 | } |
||
25 | |||
26 | 1 | return ''; |
|
27 | } |
||
28 | |||
29 | 6 | $this->value = trim(mb_substr($html, 10, $posOfEndOfDocType - 10)); |
|
30 | |||
31 | 6 | return mb_substr($html, $posOfEndOfDocType + 1); |
|
32 | } |
||
33 | |||
44 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.