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

tempestphp / tempest-framework / 14049246919

24 Mar 2025 09:42PM UTC coverage: 79.353% (-0.04%) from 79.391%
14049246919

push

github

web-flow
feat(support): support array parameters in string manipulations (#1073)

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

735 existing lines in 126 files now uncovered.

10492 of 13222 relevant lines covered (79.35%)

90.78 hits per line

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

75.76
/src/Tempest/View/src/Components/Input.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Tempest\View\Components;
6

7
use Tempest\Router\Session\Session;
8
use Tempest\Validation\Rule;
9
use Tempest\View\Elements\ViewComponentElement;
10
use Tempest\View\ViewComponent;
11

12
final readonly class Input implements ViewComponent
13
{
14
    public function __construct(
2✔
15
        private Session $session,
16
    ) {}
2✔
17

UNCOV
18
    public static function getName(): string
×
19
    {
UNCOV
20
        return 'x-input';
×
21
    }
22

23
    public function compile(ViewComponentElement $element): string
2✔
24
    {
25
        $name = $element->getAttribute('name');
2✔
26
        $label = $element->getAttribute('label');
2✔
27
        $type = $element->getAttribute('type');
2✔
28
        $default = $element->getAttribute('default');
2✔
29

30
        $errors = $this->getErrorsFor($name);
2✔
31

32
        $errorHtml = '';
2✔
33

34
        if ($errors) {
2✔
35
            $errorHtml = '<div>' . implode('', array_map(
1✔
36
                fn (Rule $failingRule) => "<div>{$failingRule->message()}</div>",
1✔
37
                $errors,
1✔
38
            )) . '</div>';
1✔
39
        }
40

41
        if ($type === 'textarea') {
2✔
UNCOV
42
            return <<<HTML
×
43
            <div>
×
44
                <label for="{$name}">{$label}</label>
×
45
                <textarea name="{$name}" id="{$name}">{$this->original($name, $default)}</textarea>
×
46
                {$errorHtml}
×
47
            </div>
UNCOV
48
            HTML;
×
49
        }
50

51
        return <<<HTML
2✔
52
        <div>
2✔
53
            <label for="{$name}">{$label}</label>
2✔
54
            <input type="{$type}" name="{$name}" id="{$name}" value="{$this->original($name, $default)}" />
2✔
55
            {$errorHtml}
2✔
56
        </div>
57
        HTML;
2✔
58
    }
59

60
    public function original(string $name, mixed $default = ''): mixed
2✔
61
    {
62
        return $this->session->get(Session::ORIGINAL_VALUES)[$name] ?? $default;
2✔
63
    }
64

65
    /** @return \Tempest\Validation\Rule[] */
66
    public function getErrorsFor(string $name): array
2✔
67
    {
68
        return $this->session->get(Session::VALIDATION_ERRORS)[$name] ?? [];
2✔
69
    }
70
}
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