PipelineAction   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%
Metric Value
wmc 8
lcom 0
cbo 3
dl 0
loc 38
ccs 17
cts 17
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 4 1
C parseArguments() 0 27 7
1
<?php
2
3
namespace Thruster\Component\Actions\Action;
4
5
use Thruster\Component\Actions\ActionInterface;
6
use Thruster\Component\Actions\ExecutorInterface;
7
use Thruster\Component\Actions\ExecutorLessInterface;
8
use function Funct\null;
9
10
/**
11
 * Class PipelineAction
12
 *
13
 * @package Thruster\Component\Actions\Action
14
 * @author  Aurimas Niekis <[email protected]>
15
 */
16
class PipelineAction extends BaseAction implements ExecutorLessInterface
17
{
18
    /**
19
     * @inheritDoc
20
     */
21 1
    public function getName() : string
22
    {
23 1
        return 'thruster_pipeline';
24
    }
25
26 5
    public function parseArguments(ExecutorInterface $executor)
27
    {
28 5
        $first = true;
29 5
        $value = null;
30
31 5
        foreach ($this->getArguments() as $argument) {
32 5
            $arguments = null($value) ? [] : [$value];
33
34 5
            if ($argument instanceof ActionInterface) {
35 3
                if (false === $first) {
36 3
                    $argument->setArguments($arguments);
37
                }
38
39 3
                $value = $executor->execute($argument);
40 4
            } elseif (is_callable($argument)) {
41 3
                $value = call_user_func_array($argument, $arguments);
42
            } else {
43 4
                $value = $argument;
44
            }
45
46 5
            if (true === $first) {
47 5
                $first = false;
48
            }
49
        }
50
51 5
        return $value;
52
    }
53
}
54