MulticastPublishRoutingConnector::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 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