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

nepada / message-bus / 11624443481

01 Nov 2024 04:43AM UTC coverage: 96.657%. Remained the same
11624443481

push

github

web-flow
Bump the phpstan group with 3 updates (#117)

318 of 329 relevant lines covered (96.66%)

0.97 hits per line

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

85.71
/src/MessageBus/Middleware/PreventNestedHandlingMiddleware.php
1
<?php
2
declare(strict_types = 1);
3

4
namespace Nepada\MessageBus\Middleware;
5

6
use Symfony\Component\Messenger\Envelope;
7
use Symfony\Component\Messenger\Exception\ExceptionInterface;
8
use Symfony\Component\Messenger\Middleware\MiddlewareInterface;
9
use Symfony\Component\Messenger\Middleware\StackInterface;
10

11
/**
12
 * Do not allow nested handling of messages.
13
 */
14
final class PreventNestedHandlingMiddleware implements MiddlewareInterface
15
{
16

17
    private bool $isHandling = false;
18

19
    /**
20
     * @throws ExceptionInterface
21
     */
22
    public function handle(Envelope $envelope, StackInterface $stack): Envelope
1✔
23
    {
24
        if ($this->isHandling) {
1✔
25
            throw new AlreadyHandlingOtherMessageException('Already handling other message.');
1✔
26
        }
27

28
        $this->isHandling = true;
1✔
29

30
        try {
31
            return $stack->next()->handle($envelope, $stack);
1✔
32
        } finally {
×
33
            $this->isHandling = false;
1✔
34
        }
35
    }
36

37
}
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