• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tempestphp / tempest-framework / 14721086338

28 Apr 2025 11:11AM UTC coverage: 80.275% (+0.03%) from 80.248%
14721086338

push

github

web-flow
refactor(container): rename #[Lazy] to #[Proxy] (#1180)

2 of 2 new or added lines in 1 file covered. (100.0%)

7 existing lines in 4 files now uncovered.

11859 of 14773 relevant lines covered (80.27%)

106.8 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

94.29
/src/Tempest/View/src/Components/DynamicViewComponent.php
1
<?php
2

3
namespace Tempest\View\Components;
4

5
use Stringable;
6
use Tempest\Core\AppConfig;
7
use Tempest\Support\Str\ImmutableString;
8
use Tempest\View\Elements\CollectionElement;
9
use Tempest\View\Elements\ViewComponentElement;
10
use Tempest\View\Parser\TempestViewCompiler;
11
use Tempest\View\Parser\Token;
12
use Tempest\View\ViewComponent;
13
use Tempest\View\ViewConfig;
14

15
use function Tempest\Support\arr;
16

17
final class DynamicViewComponent implements ViewComponent
18
{
19
    private Token $token;
20

21
    public function __construct() {}
4✔
22

23
    public function setToken(Token $token): void
4✔
24
    {
25
        $this->token = $token;
4✔
26
    }
27

UNCOV
28
    public static function getName(): string
×
29
    {
UNCOV
30
        return 'x-dynamic-component';
×
31
    }
32

33
    public function compile(ViewComponentElement $element): string
4✔
34
    {
35
        $name = $this->token->getAttribute('is') ?? $this->token->getAttribute(':is');
4✔
36

37
        $isExpression = $this->token->getAttribute(':is') !== null;
4✔
38

39
        $collectionElement = new CollectionElement($element->getChildren());
4✔
40

41
        $attributes = arr($element->getAttributes())
4✔
42
            ->filter(fn (string $_value, string $key) => $key !== 'is' && $key !== ':is')
4✔
43
            ->map(function (string $value, string $key) {
4✔
44
                return sprintf('%s="%s"', $key, trim($value));
3✔
45
            })
4✔
46
            ->implode(' ')
4✔
47
            ->when(
4✔
48
                fn (Stringable $string) => ((string) $string) !== '',
4✔
49
                fn (Stringable $string) => new ImmutableString(" {$string}"),
4✔
50
            );
4✔
51

52
        $compiledChildren = sprintf(
4✔
53
            <<<'HTML'
4✔
54
            <%s%s>
55
            %s
56
            </%s>
57
            HTML,
4✔
58
            '%s',
4✔
59
            $attributes,
4✔
60
            $collectionElement->compile(),
4✔
61
            '%s',
4✔
62
        );
4✔
63

64
        return sprintf(
4✔
65
            '<?php 
4✔
66
$vars = get_defined_vars();
67
unset($vars[\'_view\'], $vars[\'_path\'], $vars[\'_data\'], $vars[\'_propIsLocal\'], $vars[\'_isIsLocal\'], $vars[\'_previousAttributes\'], $vars[\'_previousSlots\'], $vars[\'slots\']);
68

69
echo \Tempest\get(' . \Tempest\View\Renderers\TempestViewRenderer::class . '::class)->render(\Tempest\view(sprintf(<<<\'HTML\'
4✔
70
%s
71
HTML, %s, %s), ...$vars)); ?>
72
',
4✔
73
            $compiledChildren,
4✔
74
            $isExpression ? $name : "'{$name}'",
4✔
75
            $isExpression ? $name : "'{$name}'",
4✔
76
        );
4✔
77
    }
78
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc