SendingFeature::setup()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 7
cts 7
cp 1
rs 9.9
c 0
b 0
f 0
cc 1
nc 1
nop 3
crap 1
1
<?php
2
namespace PSB\Core\Transport;
3
4
5
use PSB\Core\Feature\Feature;
6
use PSB\Core\ObjectBuilder\BuilderInterface;
7
use PSB\Core\Pipeline\PipelineModifications;
8
use PSB\Core\Util\Settings;
9
10
class SendingFeature extends Feature
11
{
12
13
    /**
14
     * Method will always be executed and should be used to determine whether to enable or disable the feature,
15
     * configure default settings, configure dependencies, configure prerequisites and register startup tasks.
16
     */
17 1
    public function describe()
18
    {
19 1
        $this->enableByDefault();
20 1
        $this->dependsOn(TransportFeature::class);
21 1
    }
22
23
    /**
24
     * Method is called if all defined conditions are met and the feature is marked as enabled.
25
     * Use this method to configure and initialize all required components for the feature like
26
     * the steps in the pipeline or the instances/factories in the container.
27
     *
28
     * @param Settings              $settings
29
     * @param BuilderInterface      $builder
30
     * @param PipelineModifications $pipelineModifications
31
     */
32 1
    public function setup(Settings $settings, BuilderInterface $builder, PipelineModifications $pipelineModifications)
33
    {
34
        /** @var OutboundTransport $outboundTransport */
35 1
        $outboundTransport = $settings->get(OutboundTransport::class);
36 1
        $sendInfrastructure = $outboundTransport->configure($settings);
37
38 1
        $builder->defineSingleton(
39 1
            MessageDispatcherInterface::class,
40 1
            $sendInfrastructure->getMessageDispatcherFactory()
41
        );
42 1
    }
43
}
44