Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
FallbackDisplayProvider
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 supports
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 createComponentFor
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2namespace Apie\HtmlBuilders\FieldDisplayProviders;
3
4use Apie\Core\ValueObjects\Utils;
5use Apie\HtmlBuilders\Components\Dashboard\RawContents;
6use Apie\HtmlBuilders\FieldDisplayBuildContext;
7use Apie\HtmlBuilders\Interfaces\ComponentInterface;
8use Apie\HtmlBuilders\Interfaces\FieldDisplayComponentProviderInterface;
9
10class FallbackDisplayProvider implements FieldDisplayComponentProviderInterface
11{
12    public function supports(mixed $object, FieldDisplayBuildContext $context): bool
13    {
14        return true;
15    }
16
17    public function createComponentFor(mixed $object, FieldDisplayBuildContext $context): ComponentInterface
18    {
19        return new RawContents('<div style="white-space: pre-wrap">' . htmlspecialchars(Utils::toString($object)) . '</div>');
20    }
21}