FailHook::failHook()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 2
Bugs 1 Features 0
Metric Value
eloc 4
c 2
b 1
f 0
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 10
cc 2
nc 2
nop 1
crap 2
1
<?php
2
3
namespace Larapie\Actions\Concerns;
4
5
use Throwable;
6
7
trait FailHook
8
{
9 6
    protected function failHook(Throwable $exception)
10
    {
11 6
        if (! method_exists($this, 'onFail')) {
12 3
            throw $exception;
13
        }
14 3
        $this->resolveAndCall($this, 'onFail', compact('exception'));
0 ignored issues
show
Bug introduced by
It seems like resolveAndCall() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

14
        $this->/** @scrutinizer ignore-call */ 
15
               resolveAndCall($this, 'onFail', compact('exception'));
Loading history...
15
16 1
        throw $exception;
17
    }
18
}
19