Always::__invoke()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 8
Ratio 100 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 2
dl 8
loc 8
ccs 5
cts 5
cp 1
crap 2
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace einfach\operation\step;
4
5
use einfach\operation\Railway;
6
use const einfach\operation\response\RESPONSE_TYPE_OK;
7
use const einfach\operation\response\RESPONSE_TYPE_ERROR;
8
9 View Code Duplication
class Always extends AbstractStep
10
{
11 6
    public function __invoke(&$params, string $track)
12
    {
13 6
        $response = $this->normalizeStepResponse(call_user_func($this->function, $params));
14
        // run on any track, but not change it to OK, if strated on Error
15 6
        $type = ($track == Railway::TRACK_FAILURE) ? RESPONSE_TYPE_ERROR : $response['type'];
16 6
        $response['type'] = $type;
17 6
        return $response;
18
    }
19
}
20