Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
3 / 3 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| YoutubeNoCookieSanitizer | |
100.00% |
3 / 3 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
| getSupportedElements | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getSupportedAttributes | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| sanitizeAttribute | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | namespace Apie\CommonValueObjects\Bridge\Symfony; |
| 3 | |
| 4 | use Symfony\Component\HtmlSanitizer\HtmlSanitizerConfig; |
| 5 | use Symfony\Component\HtmlSanitizer\Visitor\AttributeSanitizer\AttributeSanitizerInterface; |
| 6 | |
| 7 | class YoutubeNoCookieSanitizer implements AttributeSanitizerInterface |
| 8 | { |
| 9 | /** |
| 10 | * @return list<string> |
| 11 | */ |
| 12 | public function getSupportedElements(): array |
| 13 | { |
| 14 | return ['iframe']; |
| 15 | } |
| 16 | |
| 17 | /** |
| 18 | * @return list<string> |
| 19 | */ |
| 20 | public function getSupportedAttributes(): array |
| 21 | { |
| 22 | return ['src']; |
| 23 | } |
| 24 | |
| 25 | public function sanitizeAttribute(string $element, string $attribute, string $value, HtmlSanitizerConfig $config): ?string |
| 26 | { |
| 27 | return preg_replace('/^(https?:)?\/\/www\.youtube\.com\/embed\//', 'https://www.youtube-nocookie.com/embed/', $value); |
| 28 | } |
| 29 | } |