Total Complexity | 6 |
Total Lines | 34 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
13 | final class DoctrinePingConnectionMiddleware extends AbstractDoctrineMiddleware |
||
14 | 3 | { |
|
15 | private string $query; |
||
16 | |||
17 | public function __construct(ManagerRegistry $managerRegistry, string $entityManagerName, string $query = 'SELECT 1;') |
||
21 | } |
||
22 | |||
23 | 3 | protected function handleForManager( |
|
24 | EntityManagerInterface $entityManager, |
||
25 | Envelope $envelope, |
||
26 | 2 | StackInterface $stack |
|
27 | ): Envelope { |
||
28 | 2 | if (null !== $envelope->last(ConsumedByWorkerStamp::class)) { |
|
29 | $this->pingConnection($entityManager); |
||
30 | 2 | } |
|
31 | 2 | ||
32 | 2 | return $stack->next()->handle($envelope, $stack); |
|
33 | } |
||
34 | |||
35 | 2 | private function pingConnection(EntityManagerInterface $entityManager): void |
|
47 | } |
||
48 | } |
||
50 |