Passed
Push — master ( 685e2a...9f4f72 )
by Iman
03:13
created

WeRespondFrom::respondFrom()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
namespace Imanghafoori\HeyMan\Plugins\Reactions;
4
5
use Illuminate\Http\Exceptions\HttpResponseException;
6
use Imanghafoori\HeyMan\Core\BaseReaction;
7
use Imanghafoori\HeyMan\Reactions\Then;
8
9
final class WeRespondFrom extends BaseReaction
10
{
11 1
    public function weRespondFrom($callback, array $parameters = [])
12
    {
13 1
        $this->commit(func_get_args(), [static::class, 'respondFrom']);
14
15 1
        return new Then($this);
16
    }
17
18
    public static function respondFrom($method)
19
    {
20 1
        return function () use ($method) {
21 1
            throw new HttpResponseException(app()->call(...$method));
0 ignored issues
show
Bug introduced by
$method is expanded, but the parameter $callback of Illuminate\Container\Container::call() does not expect variable arguments. ( Ignorable by Annotation )

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

21
            throw new HttpResponseException(app()->call(/** @scrutinizer ignore-type */ ...$method));
Loading history...
Bug introduced by
It seems like app()->call($method) can also be of type callable; however, parameter $response of Illuminate\Http\Exceptio...xception::__construct() does only seem to accept Symfony\Component\HttpFoundation\Response, maybe add an additional type check? ( Ignorable by Annotation )

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

21
            throw new HttpResponseException(/** @scrutinizer ignore-type */ app()->call(...$method));
Loading history...
22 1
        };
23
    }
24
}