| Conditions | 2 |
| Paths | 2 |
| Total Lines | 28 |
| Code Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 2 |
| Changes | 0 | ||
| 1 | <?php |
||
| 33 | 2 | public function repair($content) |
|
| 34 | { |
||
| 35 | 2 | if (!$content) { |
|
| 36 | 1 | return ''; |
|
| 37 | } |
||
| 38 | |||
| 39 | 1 | $content = iconv('windows-1251', 'utf-8', $content); |
|
| 40 | |||
| 41 | // clean content |
||
| 42 | $config = [ |
||
| 43 | 1 | 'output-xhtml' => true, |
|
| 44 | 'indent' => true, |
||
| 45 | 'indent-spaces' => 0, |
||
| 46 | 'fix-backslash' => true, |
||
| 47 | 'hide-comments' => true, |
||
| 48 | 'drop-empty-paras' => true, |
||
| 49 | 'wrap' => false, |
||
| 50 | ]; |
||
| 51 | 1 | $this->tidy->parseString($content, $config, 'utf8'); |
|
| 52 | 1 | $this->tidy->cleanRepair(); |
|
| 53 | 1 | $content = $this->tidy->root()->value; |
|
| 54 | |||
| 55 | // ignore blocks |
||
| 56 | 1 | $content = preg_replace('/<noembed>.*?<\/noembed>/is', '', $content); |
|
| 57 | 1 | $content = preg_replace('/<noindex>.*?<\/noindex>/is', '', $content); |
|
| 58 | |||
| 59 | 1 | return $content; |
|
| 60 | } |
||
| 61 | } |
||
| 62 |