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

tempestphp / tempest-framework / 11743263957

08 Nov 2024 01:43PM UTC coverage: 82.172% (-0.3%) from 82.498%
11743263957

Pull #685

github

web-flow
Merge b9f02ce65 into 04000ace5
Pull Request #685: feat(commandbus): async commands

35 of 81 new or added lines in 6 files covered. (43.21%)

7278 of 8857 relevant lines covered (82.17%)

49.44 hits per line

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

80.0
/src/Tempest/CommandBus/src/HandleAsyncCommand.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Tempest\CommandBus;
6

7
use Tempest\Console\Console;
8
use Tempest\Console\ConsoleCommand;
9
use Tempest\Console\HasConsole;
10
use Tempest\Container\Container;
11

12
final readonly class HandleAsyncCommand
13
{
14
    use HasConsole;
15

16
    public function __construct(
1✔
17
        private CommandBusConfig $commandBusConfig,
18
        private Container $container,
19
        private Console $console,
20
        private AsyncCommandRepository $repository,
21
    ) {
22
    }
1✔
23

24
    #[ConsoleCommand(name: 'command:handle')]
1✔
25
    public function __invoke(string $uuid): void
26
    {
27
        $command = $this->repository->find($uuid);
1✔
28

29
        $commandHandler = $this->commandBusConfig->handlers[$command::class] ?? null;
1✔
30

31
        if (! $commandHandler) {
1✔
NEW
32
            $commandClass = $command::class;
×
33

NEW
34
            $this->error("No handler found for command {$commandClass}");
×
35

NEW
36
            return;
×
37
        }
38

39
        $commandHandler->handler->invokeArgs(
1✔
40
            $this->container->get($commandHandler->handler->getDeclaringClass()->getName()),
1✔
41
            [$command],
1✔
42
        );
1✔
43

44
        $this->repository->remove($uuid);
1✔
45

46
        $this->success('Done');
1✔
47
    }
48
}
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