• 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

90.91
/src/Tempest/Console/src/Components/Static/StaticSearchComponent.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Tempest\Console\Components\Static;
6

7
use Closure;
8
use Tempest\Console\Console;
9
use Tempest\Console\StaticConsoleComponent;
10

11
use function Tempest\Support\Arr\wrap;
12

13
final class StaticSearchComponent implements StaticConsoleComponent
14
{
15
    private const string CANCEL = 'Cancel';
16

17
    private const string SEARCH_AGAIN = 'Search again';
18

19
    public function __construct(
5✔
20
        public readonly string $label,
21
        public readonly Closure $search,
22
        public readonly bool $multiple = false,
23
        public null|array|string $default = null,
24
    ) {
25
        if ($this->multiple) {
5✔
UNCOV
26
            $this->default = wrap($this->default);
×
27
        }
28
    }
29

30
    public function render(Console $console): null|array|string
5✔
31
    {
32
        if (! $console->supportsPrompting()) {
5✔
33
            return $this->default;
2✔
34
        }
35

36
        do {
37
            $query = $console->ask($this->label);
3✔
38

39
            $options = $this->multiple
3✔
UNCOV
40
                ? ($this->search)($query)
×
41
                : [self::CANCEL, self::SEARCH_AGAIN, ...($this->search)($query)];
3✔
42

43
            $answer = $console->ask(
3✔
44
                question: 'Please select a result',
3✔
45
                options: $options,
3✔
46
                multiple: $this->multiple,
3✔
47
                default: $this->multiple ? [] : self::CANCEL,
3✔
48
            );
3✔
49

50
            if ($answer === self::SEARCH_AGAIN) {
3✔
51
                $answer = false;
1✔
52
            }
53

54
            if ($answer === self::CANCEL) {
3✔
55
                $answer = null;
2✔
56
            }
57
        } while ($answer === false);
3✔
58

59
        return $answer ?: $this->default;
3✔
60
    }
61
}
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