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

WeRespondFrom   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 13
ccs 5
cts 5
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A respondFrom() 0 4 1
A weRespondFrom() 0 5 1
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
}