TryCatch   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 14 3
1
<?php
2
3
namespace einfach\operation\step;
4
5
use einfach\operation\Railway;
6
use function einfach\operation\response\error;
7
8
class TryCatch extends AbstractStep
9
{
10 6
    public function __invoke(&$params, string $track)
11
    {
12
        // only on OK track
13 6
        if ($track == Railway::TRACK_SUCCESS) {
14
            try {
15 4
                $response = $this->normalizeStepResponse(call_user_func($this->function, $params));
16 2
                return $response;
17 2
            } catch (\Exception $e) {
18 2
                return $this->normalizeStepResponse(error($params, $e->getMessage()));
19
            }
20
        } else {
21 2
            $this->skip();
22
        }
23 2
    }
24
}
25