• 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

73.08
/src/Tempest/Console/src/Components/Interactive/ConfirmComponent.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Tempest\Console\Components\Interactive;
6

7
use Tempest\Console\Components\Concerns\HasErrors;
8
use Tempest\Console\Components\Concerns\HasState;
9
use Tempest\Console\Components\Concerns\RendersControls;
10
use Tempest\Console\Components\Renderers\ConfirmRenderer;
11
use Tempest\Console\Components\Static\StaticConfirmComponent;
12
use Tempest\Console\HandlesKey;
13
use Tempest\Console\HasStaticComponent;
14
use Tempest\Console\InteractiveConsoleComponent;
15
use Tempest\Console\Key;
16
use Tempest\Console\StaticConsoleComponent;
17
use Tempest\Console\Terminal\Terminal;
18

19
final class ConfirmComponent implements InteractiveConsoleComponent, HasStaticComponent
20
{
21
    use HasErrors;
22
    use HasState;
23
    use RendersControls;
24

25
    private bool $answer;
26

27
    public ConfirmRenderer $renderer;
28

29
    public function __construct(
19✔
30
        private readonly string $question,
31
        private readonly bool $default = false,
32
        readonly ?string $yes = null,
33
        readonly ?string $no = null,
34
    ) {
35
        $this->answer = $default;
19✔
36
        $this->renderer = new ConfirmRenderer($yes ?? 'Yes', $no ?? 'No');
19✔
37
    }
38

39
    public StaticConsoleComponent $staticComponent {
40
        get => new StaticConfirmComponent(
41
            $this->question,
42
            $this->default,
43
        );
44
    }
45

46
    public function render(Terminal $terminal): string
1✔
47
    {
48
        return $this->renderer->render(
1✔
49
            terminal: $terminal,
1✔
50
            state: $this->state,
1✔
51
            answer: $this->answer,
1✔
52
            label: $this->question,
1✔
53
        );
1✔
54
    }
55

UNCOV
56
    private function getControls(): array
×
57
    {
UNCOV
58
        return [
×
UNCOV
59
            '↔' => 'toggle',
×
UNCOV
60
            'enter' => 'confirm',
×
UNCOV
61
        ];
×
62
    }
63

64
    #[HandlesKey(Key::DOWN)]
1✔
65
    #[HandlesKey(Key::UP)]
66
    #[HandlesKey(Key::LEFT)]
67
    #[HandlesKey(Key::RIGHT)]
68
    public function toggle(): void
69
    {
70
        $this->answer = ! $this->answer;
1✔
71
    }
72

73
    #[HandlesKey(Key::ENTER)]
3✔
74
    public function enter(): bool
75
    {
76
        return $this->answer;
3✔
77
    }
78

79
    #[HandlesKey]
1✔
80
    public function input(string $key): void
81
    {
82
        $this->answer = match (mb_strtolower($key)) {
1✔
83
            'y', 'o' => true,
1✔
84
            'n' => false,
1✔
UNCOV
85
            'h', 'j', 'k', 'l' => ! $this->answer,
×
UNCOV
86
            default => $this->answer,
×
87
        };
1✔
88
    }
89
}
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