Completed
Push — master ( a96975...a953ec )
by Olivier
03:50 queued 10s
created

ServicesResetterProcessor   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 30
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A process() 0 8 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Swarrot\Processor\ServicesResetter;
6
7
use Swarrot\Broker\Message;
8
use Swarrot\Processor\ProcessorInterface;
9
use Symfony\Contracts\Service\ResetInterface;
10
11
/**
12
 * @author Pierrick Vignand <[email protected]>
13
 */
14
class ServicesResetterProcessor implements ProcessorInterface
15
{
16
    /**
17
     * @var ProcessorInterface
18
     */
19
    private $processor;
20
21
    /**
22
     * @var ResetInterface
23
     */
24
    private $servicesResetter;
25
26
    public function __construct(ProcessorInterface $processor, ResetInterface $servicesResetter)
27
    {
28
        $this->processor = $processor;
29
        $this->servicesResetter = $servicesResetter;
30
    }
31
32
    /**
33
     * {@inheritdoc}
34
     */
35
    public function process(Message $message, array $options)
36
    {
37
        try {
38
            return $this->processor->process($message, $options);
39
        } finally {
40
            $this->servicesResetter->reset();
41
        }
42
    }
43
}
44