Test Setup Failed
Push — master ( 8fa0e2...251f8c )
by Gabriel
08:50
created

ActionBuilder   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 8

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 8
dl 30
loc 30
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 8 8 1
A build() 11 11 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Nip\Dispatcher\Resolver\Pipeline;
4
5
use League\Pipeline\InterruptibleProcessor;
6
use League\Pipeline\PipelineBuilder as AbstractBuilder;
7
use League\Pipeline\PipelineInterface;
8
use League\Pipeline\ProcessorInterface;
9
use Nip\Dispatcher\Commands\Command;
10
use Nip\Dispatcher\Resolver\Pipeline\Stages\ActionCallStage;
11
use Nip\Dispatcher\Resolver\Pipeline\Stages\ClassInstanceStage;
12
use Nip\Dispatcher\Resolver\Pipeline\Stages\ClosureStage;
13
use Nip\Dispatcher\Resolver\Pipeline\Stages\ModuleControllerStage;
14
use Nip\Dispatcher\Resolver\Pipeline\Stages\RequestStage;
15
16
/**
17
 * Class ActionBuilder
18
 * @package Nip\Dispatcher\Resolver\Pipeline
19
 */
20 View Code Duplication
class ActionBuilder extends AbstractBuilder
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
21
{
22 5
    public function __construct()
23
    {
24 5
        $this->add(new ClosureStage());
25 5
        $this->add(new RequestStage());
26 5
        $this->add(new ModuleControllerStage());
27 5
        $this->add(new ClassInstanceStage());
28 5
        $this->add(new ActionCallStage());
29 5
    }
30
31
    /**
32
     * Build a new Pipeline object
33
     *
34
     * @param  ProcessorInterface|null $processor
35
     *
36
     * @return PipelineInterface
37
     */
38 5
    public function build(ProcessorInterface $processor = null): PipelineInterface
39
    {
40 5
        if ($processor == null) {
41 5
            $processor = new InterruptibleProcessor(
42 5
                function (Command $command) {
43 3
                    return !$command->hasReturn();
44 5
                }
45
            );
46
        }
47 5
        return parent::build($processor);
48
    }
49
}
50