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

nepada / message-bus-doctrine / 8509392190

01 Apr 2024 02:33PM UTC coverage: 98.214%. Remained the same
8509392190

Pull #108

github

web-flow
Update php-parallel-lint/php-parallel-lint requirement

Updates the requirements on [php-parallel-lint/php-parallel-lint](https://github.com/php-parallel-lint/PHP-Parallel-Lint) to permit the latest version.
- [Release notes](https://github.com/php-parallel-lint/PHP-Parallel-Lint/releases)
- [Changelog](https://github.com/php-parallel-lint/PHP-Parallel-Lint/blob/v1.4.0/CHANGELOG.md)
- [Commits](https://github.com/php-parallel-lint/PHP-Parallel-Lint/compare/v1.3.2...v1.4.0)

---
updated-dependencies:
- dependency-name: php-parallel-lint/php-parallel-lint
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #108: Update php-parallel-lint/php-parallel-lint requirement from 1.3.2 to 1.4.0

55 of 56 relevant lines covered (98.21%)

0.98 hits per line

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

100.0
/src/MessageBusDoctrine/Middleware/TransactionMiddleware.php
1
<?php
2
declare(strict_types = 1);
3

4
namespace Nepada\MessageBusDoctrine\Middleware;
5

6
use Doctrine\ORM\EntityManagerInterface;
7
use Symfony\Component\Messenger\Envelope;
8
use Symfony\Component\Messenger\Middleware\MiddlewareInterface;
9
use Symfony\Component\Messenger\Middleware\StackInterface;
10

11
class TransactionMiddleware implements MiddlewareInterface
12
{
13

14
    private EntityManagerInterface $entityManager;
15

16
    public function __construct(EntityManagerInterface $entityManager)
1✔
17
    {
18
        $this->entityManager = $entityManager;
1✔
19
    }
1✔
20

21
    public function handle(Envelope $envelope, StackInterface $stack): Envelope
1✔
22
    {
23
        $this->entityManager->beginTransaction();
1✔
24

25
        $transactionNestingLevel = $this->entityManager->getConnection()->getTransactionNestingLevel();
1✔
26

27
        try {
28
            $result = $stack->next()->handle($envelope, $stack);
1✔
29

30
            $this->assertTransactionNestingLevel($transactionNestingLevel);
1✔
31

32
            $this->entityManager->flush();
1✔
33
            $this->entityManager->commit();
1✔
34

35
            return $result;
1✔
36

37
        } catch (\Throwable $exception) {
1✔
38
            if ($this->entityManager->getConnection()->isTransactionActive()) {
1✔
39
                $this->assertTransactionNestingLevel($transactionNestingLevel, $exception);
1✔
40
                $this->entityManager->rollback();
1✔
41
                $this->entityManager->close();
1✔
42
            }
43

44
            throw $exception;
1✔
45
        }
46
    }
47

48
    private function assertTransactionNestingLevel(
1✔
49
        int $expectedTransactionNestingLevel,
50
        ?\Throwable $previousException = null,
51
    ): void
52
    {
53
        $transactionNestingLevel = $this->entityManager->getConnection()->getTransactionNestingLevel();
1✔
54

55
        if ($expectedTransactionNestingLevel !== $transactionNestingLevel) {
1✔
56
            throw new \LogicException(
1✔
57
                sprintf(
1✔
58
                    'Transaction nesting level mismatch. Expected level: %d, got: %d.',
1✔
59
                    $expectedTransactionNestingLevel,
60
                    $transactionNestingLevel,
61
                ),
62
                0,
1✔
63
                $previousException,
64
            );
65
        }
66
    }
1✔
67

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