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

tempestphp / tempest-framework / 14214561589

02 Apr 2025 08:02AM UTC coverage: 81.105% (+0.07%) from 81.035%
14214561589

Pull #1109

github

web-flow
Merge c5ed1370b into 9c84c680a
Pull Request #1109: feat(core): add middleware priority and discovery

58 of 67 new or added lines in 14 files covered. (86.57%)

29 existing lines in 10 files now uncovered.

11152 of 13750 relevant lines covered (81.11%)

102.13 hits per line

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

18.52
/src/Tempest/Console/src/Middleware/HelpMiddleware.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Tempest\Console\Middleware;
6

7
use Tempest\Console\Actions\RenderConsoleCommand;
8
use Tempest\Console\Console;
9
use Tempest\Console\ConsoleCommand;
10
use Tempest\Console\ConsoleMiddleware;
11
use Tempest\Console\ConsoleMiddlewareCallable;
12
use Tempest\Console\ExitCode;
13
use Tempest\Console\Initializers\Invocation;
14

15
final readonly class HelpMiddleware implements ConsoleMiddleware
16
{
17
    public function __construct(
111✔
18
        private Console $console,
19
    ) {}
111✔
20

21
    public function __invoke(Invocation $invocation, ConsoleMiddlewareCallable $next): ExitCode|int
111✔
22
    {
23
        if ($invocation->argumentBag->get('-h') || $invocation->argumentBag->get('help')) {
111✔
UNCOV
24
            $this->renderHelp($invocation->consoleCommand);
×
25

26
            return ExitCode::SUCCESS;
×
27
        }
28

29
        return $next($invocation);
111✔
30
    }
31

UNCOV
32
    private function renderHelp(ConsoleCommand $consoleCommand): void
×
33
    {
34
        $this->console->header(
×
UNCOV
35
            header: $consoleCommand->getName(),
×
36
            subheader: $consoleCommand->description,
×
37
        );
×
38

39
        $this->console->header('Usage');
×
UNCOV
40
        (new RenderConsoleCommand($this->console, renderArguments: true, renderDescription: false))($consoleCommand);
×
41

42
        if ($consoleCommand->help) {
×
UNCOV
43
            $this->console->writeln();
×
44
            $this->console->writeln('<style="fg-gray">' . $consoleCommand->help . '</style>');
×
45
        }
46

UNCOV
47
        foreach ($consoleCommand->getArgumentDefinitions() as $argumentDefinition) {
×
UNCOV
48
            if ($argumentDefinition->aliases === [] && ! $argumentDefinition->description && ! $argumentDefinition->help) {
×
49
                continue;
×
50
            }
51

UNCOV
52
            $this->console
×
UNCOV
53
                ->writeln()
×
54
                ->write("<style=\"underline\">{$argumentDefinition->name}</style>")
×
55
                ->when($argumentDefinition->aliases !== [], fn (Console $console) => $console->write(' (' . implode(', ', $argumentDefinition->aliases) . ')'))
×
56
                ->when($argumentDefinition->description, fn (Console $console) => $console->writeln()->writeln($argumentDefinition->description))
×
57
                ->when($argumentDefinition->help, fn (Console $console) => $console->writeln()->writeln('<style="fg-gray">' . $argumentDefinition->help . '</style>'));
×
58
        }
59

UNCOV
60
        $this->console->writeln();
×
61
    }
62
}
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