MulticastPublishRoutingConnector   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 44
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A invoke() 0 8 1
A getStageContextClass() 0 4 1
A getNextStageContextClass() 0 4 1
1
<?php
2
namespace PSB\Core\Routing\Pipeline;
3
4
5
use PSB\Core\HeaderTypeEnum;
6
use PSB\Core\MessageIntentEnum;
7
use PSB\Core\Pipeline\Outgoing\OutgoingContextFactory;
8
use PSB\Core\Pipeline\Outgoing\StageContext\OutgoingLogicalMessageContext;
9
use PSB\Core\Pipeline\Outgoing\StageContext\OutgoingPublishContext;
10
use PSB\Core\Pipeline\StageConnectorInterface;
11
12
class MulticastPublishRoutingConnector implements StageConnectorInterface
13
{
14
    /**
15
     * @var OutgoingContextFactory
16
     */
17
    private $contextFactory;
18
19
    /**
20
     * @param OutgoingContextFactory $contextFactory
21
     */
22 5
    public function __construct(OutgoingContextFactory $contextFactory)
23
    {
24 5
        $this->contextFactory = $contextFactory;
25 5
    }
26
27
    /**
28
     * @param OutgoingPublishContext $context
29
     * @param callable               $next
30
     */
31 2
    public function invoke($context, callable $next)
32
    {
33 2
        $context->setHeader(HeaderTypeEnum::MESSAGE_INTENT, MessageIntentEnum::PUBLISH);
34
35 2
        $logicalMesageContext = $this->contextFactory->createLogicalMessageContextFromPublishContext($context);
36
37 2
        $next($logicalMesageContext);
38 2
    }
39
40
    /**
41
     * @return string
42
     */
43 1
    public static function getStageContextClass()
44
    {
45 1
        return OutgoingPublishContext::class;
46
    }
47
48
    /**
49
     * @return string
50
     */
51 1
    public static function getNextStageContextClass()
52
    {
53 1
        return OutgoingLogicalMessageContext::class;
54
    }
55
}
56