Completed
Push — master ( be02a5...a1ec95 )
by Nick
22:04 queued 02:39
created

Policy::test()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace EloquentJs\Query\Guard\Policy;
4
5
use EloquentJs\Query\MethodCall;
6
7
class Policy
8
{
9
    /**
10
     * @var Rule[]
11
     */
12
    protected $rules;
13
14
    /**
15
     * Create a new Policy instance.
16
     *
17
     * @param array $rules
18
     */
19
    public function __construct(array $rules = [])
20
    {
21
        $this->rules = $rules;
22
    }
23
24
    /**
25
     * Test if the method call is allowed by this policy.
26
     *
27
     * @param MethodCall $call
28
     * @return bool
29
     */
30
    public function test(MethodCall $call)
31
    {
32
        return !! array_first($this->rules, function ($index, $rule) use ($call) {
33
            return $rule->test($call);
34
        });
35
    }
36
}
37