Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
66.67% covered (warning)
66.67%
2 / 3
66.67% covered (warning)
66.67%
2 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
RichText
66.67% covered (warning)
66.67%
2 / 3
66.67% covered (warning)
66.67%
2 / 3
3.33
0.00% covered (danger)
0.00%
0 / 1
 __toString
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 clean
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 excerpt
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace Cosray\Value;
6
7use Cosray\Util\Html as HtmlUtil;
8use Symfony\Component\HtmlSanitizer\HtmlSanitizerConfig;
9
10class RichText extends Text
11{
12    public function __toString(): string
13    {
14        return $this->clean();
15    }
16
17    public function clean(
18        ?HtmlSanitizerConfig $config = null,
19        bool $removeEmptyLines = true,
20    ): string {
21        return HtmlUtil::sanitize($this->unwrap(), $config, $removeEmptyLines);
22    }
23
24    public function excerpt(
25        int $words = 30,
26        string $allowedTags = '',
27    ): string {
28        return HtmlUtil::excerpt($this->unwrap(), $words, $allowedTags);
29    }
30}