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

tempestphp / tempest-framework / 14024978163

23 Mar 2025 05:55PM UTC coverage: 79.391% (-0.05%) from 79.441%
14024978163

push

github

web-flow
feat(view): cache Blade and Twig templates in internal storage (#1061)

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

912 existing lines in 110 files now uncovered.

10478 of 13198 relevant lines covered (79.39%)

91.09 hits per line

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

96.3
/src/Tempest/View/src/Elements/GenericElement.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Tempest\View\Elements;
6

7
use Tempest\View\Element;
8

9
use function Tempest\Support\Html\is_void_tag;
10
use function Tempest\Support\str;
11

12
final class GenericElement implements Element
13
{
14
    use IsElement;
15

16
    private array $rawAttributes = [];
17

18
    public function __construct(
94✔
19
        private readonly string $tag,
20
        array $attributes,
21
    ) {
22
        $this->attributes = $attributes;
94✔
23
    }
24

25
    public function getTag(): string
1✔
26
    {
27
        return $this->tag;
1✔
28
    }
29

30
    public function addRawAttribute(string $attribute): self
1✔
31
    {
32
        $this->rawAttributes[] = $attribute;
1✔
33

34
        return $this;
1✔
35
    }
36

37
    public function compile(): string
88✔
38
    {
39
        $content = [];
88✔
40

41
        foreach ($this->getChildren() as $child) {
88✔
42
            $content[] = $child->compile();
70✔
43
        }
44

45
        $content = implode('', $content);
88✔
46

47
        $attributes = [];
88✔
48

49
        foreach ($this->getAttributes() as $name => $value) {
88✔
50
            $name = str($name);
51✔
51

52
            if ($name->startsWith(':')) {
51✔
UNCOV
53
                $name = ':' . $name->kebab()->toString();
×
54
            } else {
55
                $name = $name->kebab()->toString();
51✔
56
            }
57

58
            if ($value) {
51✔
59
                $attributes[] = $name . '="' . $value . '"';
51✔
60
            } else {
61
                $attributes[] = $name;
2✔
62
            }
63
        }
64

65
        $attributes = implode(' ', [...$attributes, ...$this->rawAttributes]);
88✔
66

67
        if ($attributes !== '') {
88✔
68
            $attributes = ' ' . $attributes;
51✔
69
        }
70

71
        // Void elements
72
        if (is_void_tag($this->tag)) {
88✔
73
            return "<{$this->tag}{$attributes}>";
8✔
74
        }
75

76
        return "<{$this->tag}{$attributes}>{$content}</{$this->tag}>";
88✔
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

© 2026 Coveralls, Inc