TransportFeature::setup()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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