Completed
Push — master ( 6af785...cbc83f )
by Iman
05:36
created

Callbacks   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A thisClosureShouldAllow() 0 3 1
A thisMethodShouldAllow() 0 4 1
A thisValueShouldAllow() 0 4 1
1
<?php
2
3
namespace Imanghafoori\HeyMan\Conditions;
4
5
trait Callbacks
6
{
7
8
    public function thisClosureShouldAllow(callable $callback, array $parameters = [])
9
    {
10
        return $this->thisMethodShouldAllow($callback, $parameters);
11
    }
12
13
    public function thisMethodShouldAllow($callback, array $parameters = [])
14
    {
15
        return function (...$payload) use ($callback, $parameters) {
16
            return (bool) app()->call($callback, array_merge($parameters, ...$payload));
17
        };
18
    }
19
20
    public function thisValueShouldAllow($value)
21
    {
22
        return function () use ($value) {
23
            return (bool) $value;
24
        };
25
    }
26
}