createInvokeHandlerContext()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 17

Duplication

Lines 17
Ratio 100 %

Code Coverage

Tests 12
CRAP Score 1

Importance

Changes 0
Metric Value
dl 17
loc 17
ccs 12
cts 12
cp 1
rs 9.7
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 1
1
<?php
2
namespace PSB\Core\Pipeline\Incoming;
3
4
5
use PSB\Core\MessageHandlerInterface;
6
use PSB\Core\OutgoingOptionsFactory;
7
use PSB\Core\Pipeline\BusOperations;
8
use PSB\Core\Pipeline\Incoming\StageContext\IncomingLogicalMessageContext;
9
use PSB\Core\Pipeline\Incoming\StageContext\IncomingPhysicalMessageContext;
10
use PSB\Core\Pipeline\Incoming\StageContext\InvokeHandlerContext;
11
use PSB\Core\Pipeline\Incoming\StageContext\TransportReceiveContext;
12
use PSB\Core\Pipeline\PendingTransportOperations;
13
14
class IncomingContextFactory
15
{
16
    /**
17
     * @var BusOperations
18
     */
19
    private $busOperations;
20
21
    /**
22
     * @var OutgoingOptionsFactory
23
     */
24
    private $outgoingOptionsFactory;
25
26
    /**
27
     * @param BusOperations          $busOperations
28
     * @param OutgoingOptionsFactory $outgoingOptionsFactory
29
     */
30 4
    public function __construct(
31
        BusOperations $busOperations,
32
        OutgoingOptionsFactory $outgoingOptionsFactory
33
    ) {
34 4
        $this->busOperations = $busOperations;
35 4
        $this->outgoingOptionsFactory = $outgoingOptionsFactory;
36 4
    }
37
38
    /**
39
     * @param TransportReceiveContext $parentContext
40
     *
41
     * @return IncomingPhysicalMessageContext
42
     */
43 1
    public function createPhysicalMessageContext(TransportReceiveContext $parentContext)
44
    {
45 1
        $physicalMessage = $parentContext->getMessage();
46 1
        return new IncomingPhysicalMessageContext(
47 1
            $physicalMessage,
48 1
            $physicalMessage->getMessageId(),
49 1
            $physicalMessage->getHeaders(),
50 1
            new PendingTransportOperations(),
51 1
            $this->busOperations,
52 1
            $this->outgoingOptionsFactory,
53 1
            $parentContext->getEndpointControlToken(),
54 1
            $parentContext
55
        );
56
    }
57
58
    /**
59
     * @param IncomingLogicalMessage         $logicalMessage
60
     * @param IncomingPhysicalMessageContext $parentContext
61
     *
62
     * @return IncomingLogicalMessageContext
63
     */
64 1 View Code Duplication
    public function createLogicalMessageContext(
65
        IncomingLogicalMessage $logicalMessage,
66
        IncomingPhysicalMessageContext $parentContext
67
    ) {
68 1
        return new IncomingLogicalMessageContext(
69 1
            $logicalMessage,
70 1
            $parentContext->getMessageId(),
71 1
            $parentContext->getHeaders(),
72 1
            $parentContext->getIncomingPhysicalMessage(),
73 1
            $parentContext->getPendingTransportOperations(),
74 1
            $this->busOperations,
75 1
            $this->outgoingOptionsFactory,
76 1
            $parentContext->getEndpointControlToken(),
77 1
            $parentContext
78
        );
79
    }
80
81
    /**
82
     * @param MessageHandlerInterface       $messageHandler
83
     * @param IncomingLogicalMessageContext $parentContext
84
     *
85
     * @return InvokeHandlerContext
86
     */
87 1 View Code Duplication
    public function createInvokeHandlerContext(
88
        MessageHandlerInterface $messageHandler,
89
        IncomingLogicalMessageContext $parentContext
90
    ) {
91 1
        return new InvokeHandlerContext(
92 1
            $messageHandler,
93 1
            $parentContext->getMessage()->getMessageInstance(),
94 1
            $parentContext->getMessageId(),
95 1
            $parentContext->getHeaders(),
96 1
            $parentContext->getIncomingPhysicalMessage(),
97 1
            $parentContext->getPendingTransportOperations(),
98 1
            $this->busOperations,
99 1
            $this->outgoingOptionsFactory,
100 1
            $parentContext->getEndpointControlToken(),
101 1
            $parentContext
102
        );
103
    }
104
}
105