• 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

94.29
/src/Tempest/Console/src/Middleware/InvalidCommandMiddleware.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Tempest\Console\Middleware;
6

7
use BackedEnum;
8
use Tempest\Console\Actions\ExecuteConsoleCommand;
9
use Tempest\Console\Console;
10
use Tempest\Console\ConsoleMiddleware;
11
use Tempest\Console\ConsoleMiddlewareCallable;
12
use Tempest\Console\Exceptions\InvalidCommandException;
13
use Tempest\Console\ExitCode;
14
use Tempest\Console\Initializers\Invocation;
15
use Tempest\Console\Input\ConsoleInputArgument;
16
use Tempest\Validation\Rules\Enum;
17
use Tempest\Validation\Rules\IsBoolean;
18
use Tempest\Validation\Rules\NotEmpty;
19
use Tempest\Validation\Rules\Numeric;
20

21
use function Tempest\Support\str;
22

23
final readonly class InvalidCommandMiddleware implements ConsoleMiddleware
24
{
25
    public function __construct(
99✔
26
        private Console $console,
27
        private ExecuteConsoleCommand $executeConsoleCommand,
28
    ) {
29
    }
99✔
30

31
    public function __invoke(Invocation $invocation, ConsoleMiddlewareCallable $next): ExitCode|int
99✔
32
    {
33
        try {
34
            return $next($invocation);
99✔
35
        } catch (InvalidCommandException $invalidCommandException) {
4✔
36
            return $this->retry($invocation, $invalidCommandException);
4✔
37
        }
38
    }
39

40
    private function retry(Invocation $invocation, InvalidCommandException $exception): ExitCode|int
4✔
41
    {
42
        $this->console->header(
4✔
43
            header: $invocation->consoleCommand->getName(),
4✔
44
            subheader: $invocation->consoleCommand->description,
4✔
45
        );
4✔
46

47
        foreach ($exception->invalidArguments as $argument) {
4✔
48
            $isEnum = is_a($argument->type, BackedEnum::class, allow_string: true);
4✔
49

50
            $value = $this->console->ask(
4✔
51
                question: str($argument->name)->snake(' ')->upperFirst()->toString(),
4✔
52
                options: $isEnum ? $argument->type::cases() : null,
4✔
53
                default: $argument->default,
4✔
54
                hint: $argument->help ?? $argument->description,
4✔
55
                validation: array_filter([
4✔
56
                    $isEnum
4✔
57
                        ? new Enum($argument->type)
2✔
58
                        : new NotEmpty(),
4✔
59
                    match ($argument->type) {
4✔
UNCOV
60
                        'bool' => new IsBoolean(),
×
UNCOV
61
                        'int' => new Numeric(),
×
62
                        default => null,
4✔
63
                    },
4✔
64
                ]),
4✔
65
            );
4✔
66

67
            $invocation->argumentBag->add(new ConsoleInputArgument(
3✔
68
                name: $argument->name,
3✔
69
                position: $argument->position,
3✔
70
                value: $value,
3✔
71
            ));
3✔
72
        }
73

74
        return ($this->executeConsoleCommand)($invocation->consoleCommand->getName());
3✔
75
    }
76
}
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