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

Callbacks   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 6
dl 0
loc 18
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A thisMethodShouldAllow() 0 4 1
A thisValueShouldAllow() 0 4 1
A thisClosureShouldAllow() 0 3 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