Code Duplication    Length = 30-30 lines in 2 locations

src/Resolver/Pipeline/ActionBuilder.php 1 location

@@ 20-49 (lines=30) @@
17
 * Class ActionBuilder
18
 * @package Nip\Dispatcher\Resolver\Pipeline
19
 */
20
class ActionBuilder extends AbstractBuilder
21
{
22
    public function __construct()
23
    {
24
        $this->add(new ClosureStage());
25
        $this->add(new RequestStage());
26
        $this->add(new ModuleControllerStage());
27
        $this->add(new ClassInstanceStage());
28
        $this->add(new ActionCallStage());
29
    }
30
31
    /**
32
     * Build a new Pipeline object
33
     *
34
     * @param  ProcessorInterface|null $processor
35
     *
36
     * @return PipelineInterface
37
     */
38
    public function build(ProcessorInterface $processor = null): PipelineInterface
39
    {
40
        if ($processor == null) {
41
            $processor = new InterruptibleProcessor(
42
                function (Command $command) {
43
                    return !$command->hasReturn();
44
                }
45
            );
46
        }
47
        return parent::build($processor);
48
    }
49
}
50

src/Resolver/Pipeline/InstanceBuilder.php 1 location

@@ 22-51 (lines=30) @@
19
 * Class InstanceBuilder
20
 * @package Nip\Dispatcher\Resolver\Pipeline
21
 */
22
class InstanceBuilder extends AbstractBuilder
23
{
24
    public function __construct()
25
    {
26
        $this->add(new ClosureStage());
27
        $this->add(new RequestStage());
28
        $this->add(new ModuleControllerStage());
29
        $this->add(new ClassInstanceStage());
30
        $this->add(new MethodCallStage());
31
    }
32
33
    /**
34
     * Build a new Pipeline object
35
     *
36
     * @param  ProcessorInterface|null $processor
37
     *
38
     * @return PipelineInterface
39
     */
40
    public function build(ProcessorInterface $processor = null): PipelineInterface
41
    {
42
        if ($processor == null) {
43
            $processor = new InterruptibleProcessor(
44
                function (Command $command) {
45
                    return !$command->hasActionParam('instance');
46
                }
47
            );
48
        }
49
        return parent::build($processor);
50
    }
51
}
52