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

ActionBuilder::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 8
Ratio 100 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 0
Metric Value
dl 8
loc 8
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
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