Completed
Push — master ( 948dd8...416797 )
by Iman
09:03
created

Callbacks::thisValueShouldAllow()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Imanghafoori\HeyMan\Conditions\Traits;
4
5
trait Callbacks
6
{
7
    public function thisClosureShouldAllow(callable $callback, array $parameters = [])
8
    {
9
        return $this->thisMethodShouldAllow($callback, $parameters);
10
    }
11
12
    public function thisMethodShouldAllow($callback, array $parameters = [])
13
    {
14
        return function (...$payload) use ($callback, $parameters) {
15
            return (bool) app()->call($callback, array_merge($parameters, ...$payload));
16
        };
17
    }
18
19
    public function thisValueShouldAllow($value)
20
    {
21
        return function () use ($value) {
22
            return (bool) $value;
23
        };
24
    }
25
}
26