Code Duplication    Length = 40-45 lines in 3 locations

src/MessageMutation/IncomingMessageMutationFeature.php 1 location

@@ 14-56 (lines=43) @@
11
use PSB\Core\Pipeline\PipelineModifications;
12
use PSB\Core\Util\Settings;
13
14
class IncomingMessageMutationFeature extends Feature
15
{
16
17
    /**
18
     * Method will always be executed and should be used to determine whether to enable or disable the feature,
19
     * configure default settings, configure dependencies, configure prerequisites and register startup tasks.
20
     */
21
    public function describe()
22
    {
23
        $this->enableByDefault();
24
    }
25
26
    /**
27
     * Method is called if all defined conditions are met and the feature is marked as enabled.
28
     * Use this method to configure and initialize all required components for the feature like
29
     * the steps in the pipeline or the instances/factories in the container.
30
     *
31
     * @param Settings              $settings
32
     * @param BuilderInterface      $builder
33
     * @param PipelineModifications $pipelineModifications
34
     */
35
    public function setup(Settings $settings, BuilderInterface $builder, PipelineModifications $pipelineModifications)
36
    {
37
        $pipelineModifications->registerStep(
38
            'IncomingLogicalMessageMutation',
39
            IncomingLogicalMessageMutationPipelineStep::class,
40
            function () use ($builder) {
41
                return new IncomingLogicalMessageMutationPipelineStep(
42
                    $builder->build(MessageMutatorRegistry::class),
43
                    $builder->build(IncomingLogicalMessageFactory::class)
44
                );
45
            }
46
        );
47
48
        $pipelineModifications->registerStep(
49
            'IncomingPhysicalMessageMutation',
50
            IncomingPhysicalMessageMutationPipelineStep::class,
51
            function () use ($builder) {
52
                return new IncomingPhysicalMessageMutationPipelineStep($builder->build(MessageMutatorRegistry::class));
53
            }
54
        );
55
    }
56
}
57

src/MessageMutation/OutgoingMessageMutationFeature.php 1 location

@@ 13-52 (lines=40) @@
10
use PSB\Core\Pipeline\PipelineModifications;
11
use PSB\Core\Util\Settings;
12
13
class OutgoingMessageMutationFeature extends Feature
14
{
15
16
    /**
17
     * Method will always be executed and should be used to determine whether to enable or disable the feature,
18
     * configure default settings, configure dependencies, configure prerequisites and register startup tasks.
19
     */
20
    public function describe()
21
    {
22
        $this->enableByDefault();
23
    }
24
25
    /**
26
     * Method is called if all defined conditions are met and the feature is marked as enabled.
27
     * Use this method to configure and initialize all required components for the feature like
28
     * the steps in the pipeline or the instances/factories in the container.
29
     *
30
     * @param Settings              $settings
31
     * @param BuilderInterface      $builder
32
     * @param PipelineModifications $pipelineModifications
33
     */
34
    public function setup(Settings $settings, BuilderInterface $builder, PipelineModifications $pipelineModifications)
35
    {
36
        $pipelineModifications->registerStep(
37
            'OutgoingLogicalMessageMutation',
38
            OutgoingLogicalMessageMutationPipelineStep::class,
39
            function () use ($builder) {
40
                return new OutgoingLogicalMessageMutationPipelineStep($builder->build(MessageMutatorRegistry::class));
41
            }
42
        );
43
44
        $pipelineModifications->registerStep(
45
            'OutgoingPhysicalMessageMutation',
46
            OutgoingPhysicalMessageMutationPipelineStep::class,
47
            function () use ($builder) {
48
                return new OutgoingPhysicalMessageMutationPipelineStep($builder->build(MessageMutatorRegistry::class));
49
            }
50
        );
51
    }
52
}
53

src/Pipeline/IncomingPipelineFeature.php 1 location

@@ 13-57 (lines=45) @@
10
use PSB\Core\Pipeline\Incoming\LoadHandlersConnector;
11
use PSB\Core\Util\Settings;
12
13
class IncomingPipelineFeature extends Feature
14
{
15
16
    /**
17
     * Method will always be executed and should be used to determine whether to enable or disable the feature,
18
     * configure default settings, configure dependencies, configure prerequisites and register startup tasks.
19
     */
20
    public function describe()
21
    {
22
        $this->enableByDefault();
23
    }
24
25
    /**
26
     * Method is called if all defined conditions are met and the feature is marked as enabled.
27
     * Use this method to configure and initialize all required components for the feature like
28
     * the steps in the pipeline or the instances/factories in the container.
29
     *
30
     * @param Settings              $settings
31
     * @param BuilderInterface      $builder
32
     * @param PipelineModifications $pipelineModifications
33
     */
34
    public function setup(
35
        Settings $settings,
36
        BuilderInterface $builder,
37
        PipelineModifications $pipelineModifications
38
    ) {
39
        $pipelineModifications->registerStep(
40
            'LoadHandlersConnector',
41
            LoadHandlersConnector::class,
42
            function () use ($builder) {
43
                return new LoadHandlersConnector(
44
                    $builder->build(MessageHandlerRegistry::class),
45
                    $builder->build(IncomingContextFactory::class)
46
                );
47
            }
48
        );
49
        $pipelineModifications->registerStep(
50
            'InvokeHandlerTerminator',
51
            InvokeHandlerTerminator::class,
52
            function () use ($builder) {
53
                return new InvokeHandlerTerminator();
54
            }
55
        );
56
    }
57
}
58