Completed
Push — master ( 44676f...b7bc18 )
by Jens
13:18
created

CorrelationIdSubscriber::onBefore()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 4
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
crap 2
1
<?php
2
/**
3
 * @author @jayS-de <[email protected]>
4
 */
5
6
namespace Commercetools\Core\Helper\Subscriber;
7
8
use Commercetools\Core\Helper\CorrelationIdProvider;
9
use Commercetools\Core\Response\AbstractApiResponse;
10
use GuzzleHttp\Event\BeforeEvent;
11
use GuzzleHttp\Event\RequestEvents;
12
use GuzzleHttp\Event\SubscriberInterface;
13
14 View Code Duplication
class CorrelationIdSubscriber implements SubscriberInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
15
{
16
    /**
17
     * @var CorrelationIdProvider
18
     */
19
    private $provider;
20
21
    public function __construct(CorrelationIdProvider $provider)
22
    {
23
        $this->provider = $provider;
24
    }
25
26
    public function getEvents()
27
    {
28
        return ['before' => ['onBefore', RequestEvents::PREPARE_REQUEST - 10]];
29
    }
30
31
    public function onBefore(BeforeEvent $event, $name)
32
    {
33
        $event->getRequest()->addHeader(AbstractApiResponse::X_CORRELATION_ID, $this->provider->getCorrelationId());
34
    }
35
}
36