Passed
Push — master ( 506468...810608 )
by Iman
09:59
created

Callbacks::valueAllows()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 0
cts 0
cp 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
namespace Imanghafoori\HeyMan\Conditions\Traits;
4
5
class Callbacks
6
{
7 4
    public function closureAllows($emptyString, $callback, $parameters = [])
8
    {
9 4
        // laravel bug :
10
        // it is not clear why laravel passes the $emptyString as the first parameter here.
11
        // check Imanghafoori\HeyMan\Conditions\ConditionsFacade class line 12;
12
13
        return $this->methodAllows($emptyString, $callback, $parameters);
14 6
    }
15 6
16 6
    public function methodAllows($emptyString, $callback, array $parameters = [])
0 ignored issues
show
Unused Code introduced by
The parameter $emptyString is not used and could be removed. ( Ignorable by Annotation )

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

16
    public function methodAllows(/** @scrutinizer ignore-unused */ $emptyString, $callback, array $parameters = [])

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
17
    {
18
        // it is not clear why laravel passes the $emptyString as the first parameter here.
19
        // check Imanghafoori\HeyMan\Conditions\ConditionsFacade class line 12;
20
21 82
        return function (...$payload) use ($callback, $parameters) {
22 54
            return (bool) app()->call($callback, array_merge($parameters, ...$payload));
23 82
        };
24
    }
25
26
    public function valueAllows($value)
27
    {
28
        return function () use ($value) {
29
            return (bool) $value;
30
        };
31
    }
32
}
33