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

tempestphp / tempest-framework / 12021213285

26 Nov 2024 12:18AM UTC coverage: 77.441% (-2.0%) from 79.441%
12021213285

Pull #754

github

web-flow
Merge 46eda39bc into cc0c7eea3
Pull Request #754: feat(framework): overhaul console interactions

734 of 1174 new or added lines in 55 files covered. (62.52%)

54 existing lines in 12 files now uncovered.

8239 of 10639 relevant lines covered (77.44%)

60.83 hits per line

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

45.45
/src/Tempest/Console/src/HasConsole.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Tempest\Console;
6

7
use Closure;
8
use Tempest\Container\Inject;
9

10
trait HasConsole
11
{
12
    #[Inject]
13
    private readonly Console $console;
14

15
    public function readln(): string
×
16
    {
17
        return $this->console->readln();
×
18
    }
19

20
    public function read(int $bytes): string
×
21
    {
22
        return $this->console->read($bytes);
×
23
    }
24

25
    public function write(string $contents): self
×
26
    {
27
        $this->console->write($contents);
×
28

29
        return $this;
×
30
    }
31

32
    public function writeln(string $line = ''): self
15✔
33
    {
34
        $this->console->writeln($line);
15✔
35

36
        return $this;
15✔
37
    }
38

39
    /**
40
     * @param mixed|null $default
41
     * @param \Tempest\Validation\Rule[] $validation
42
     */
43
    public function ask(
1✔
44
        string $question,
45
        ?array $options = null,
46
        mixed $default = null,
47
        bool $multiple = false,
48
        bool $multiline = false,
49
        ?string $placeholder = null,
50
        ?string $hint = null,
51
        array $validation = [],
52
    ): string|array {
53
        return $this->console->ask(
1✔
54
            question: $question,
1✔
55
            options: $options,
1✔
56
            default: $default,
1✔
57
            multiple: $multiple,
1✔
58
            multiline: $multiline,
1✔
59
            placeholder: $placeholder,
1✔
60
            hint: $hint,
1✔
61
            validation: $validation,
1✔
62
        );
1✔
63
    }
64

65
    public function confirm(string $question, bool $default = false): bool
5✔
66
    {
67
        return $this->console->confirm(
5✔
68
            question: $question,
5✔
69
            default: $default,
5✔
70
        );
5✔
71
    }
72

73
    public function password(string $label = 'Password', bool $confirm = false): string
×
74
    {
75
        return $this->console->password(
×
76
            label: $label,
×
77
            confirm: $confirm,
×
78
        );
×
79
    }
80

81
    public function progressBar(iterable $data, Closure $handler): array
×
82
    {
83
        return $this->console->progressBar(
×
84
            data: $data,
×
85
            handler: $handler,
×
86
        );
×
87
    }
88

89
    /**
90
     * @param Closure(string $search): array $search
91
     */
NEW
92
    public function search(string $label, Closure $search, bool $multiple = false, null|string|array $default = null): mixed
×
93
    {
94
        return $this->console->search(
×
95
            label: $label,
×
96
            search: $search,
×
NEW
97
            multiple: $multiple,
×
NEW
98
            default: $default,
×
UNCOV
99
        );
×
100
    }
101

102
    public function info(string $line, ?string $symbol = null): self
3✔
103
    {
104
        $this->console->info($line, $symbol);
3✔
105

106
        return $this;
3✔
107
    }
108

NEW
109
    public function error(string $line, ?string $symbol = null): self
×
110
    {
NEW
111
        $this->console->error($line, $symbol);
×
112

UNCOV
113
        return $this;
×
114
    }
115

NEW
116
    public function warning(string $line, ?string $symbol = null): self
×
117
    {
NEW
118
        $this->console->warning($line, $symbol);
×
119

120
        return $this;
×
121
    }
122

123
    public function success(string $line, ?string $symbol = null): self
16✔
124
    {
125
        $this->console->success($line, $symbol);
16✔
126

127
        return $this;
16✔
128
    }
129
}
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