Failure   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 16
loc 16
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 13 13 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 einfach\operation\step;
4
5
use einfach\operation\Railway;
6
use const einfach\operation\response\RESPONSE_TYPE_ERROR;
7
8 View Code Duplication
class Failure extends AbstractStep
9
{
10 6
    public function __invoke(&$params, string $track)
11
    {
12
        // works only on Error track
13 6
        if ($track == Railway::TRACK_FAILURE) {
14 4
            $response = call_user_func($this->function, $params);
15 4
            $response = $this->normalizeStepResponse($response);
16
            // does not respect function return and always back to error track
17 4
            $response['type'] = RESPONSE_TYPE_ERROR;
18 4
            return $response;
19
        } else {
20 2
            $this->skip();
21
        }
22 2
    }
23
}
24