Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
33.33% covered (danger)
33.33%
1 / 3
50.00% covered (danger)
50.00%
1 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
SafeHtmlDisplayProvider
33.33% covered (danger)
33.33%
1 / 3
50.00% covered (danger)
50.00%
1 / 2
3.19
0.00% covered (danger)
0.00%
0 / 1
 supports
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 createComponentFor
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2namespace Apie\HtmlBuilders\FieldDisplayProviders;
3
4use Apie\CommonValueObjects\SafeHtml;
5use Apie\HtmlBuilders\Components\Dashboard\RawContents;
6use Apie\HtmlBuilders\FieldDisplayBuildContext;
7use Apie\HtmlBuilders\Interfaces\ComponentInterface;
8use Apie\HtmlBuilders\Interfaces\FieldDisplayComponentProviderInterface;
9
10final class SafeHtmlDisplayProvider implements FieldDisplayComponentProviderInterface
11{
12    public function supports(mixed $object, FieldDisplayBuildContext $context): bool
13    {
14        return $object instanceof SafeHtml;
15    }
16
17    public function createComponentFor(mixed $object, FieldDisplayBuildContext $context): ComponentInterface
18    {
19        assert($object instanceof SafeHtml);
20        return new RawContents($object);
21    }
22}