DoctrineClearEntityManagerMiddleware   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 12
ccs 4
cts 4
cp 1
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A handleForManager() 0 10 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace TMV\Messenger\Middleware;
6
7
use Doctrine\ORM\EntityManagerInterface;
8
use Symfony\Component\Messenger\Envelope;
9
use Symfony\Component\Messenger\Middleware\StackInterface;
10
use Symfony\Component\Messenger\Stamp\ReceivedStamp;
11
12
class DoctrineClearEntityManagerMiddleware extends AbstractDoctrineMiddleware
13
{
14 2
    protected function handleForManager(
15
        EntityManagerInterface $entityManager,
16
        Envelope $envelope,
17
        StackInterface $stack
18
    ): Envelope {
19
        try {
20 2
            return $stack->next()->handle($envelope, $stack);
21
        } finally {
22 2
            if (null !== $envelope->last(ReceivedStamp::class)) {
23 2
                $entityManager->clear();
24
            }
25
        }
26
    }
27
}
28