Completed
Push — master ( 15f051...29343b )
by Oleg
05:33
created

DisplayRule::canDisplay()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 9.4285
cc 2
eloc 4
nc 2
nop 0
crap 2
1
<?php
2
3
namespace Malezha\Menu\Traits;
4
5
trait DisplayRule
6
{
7
    protected $rule = true;
8
9
    /**
10
     * @param mixed $rule
11
     */
12 1
    public function setDisplayRule($rule)
13
    {
14 1
        $this->rule = $rule;
15 1
    }
16
17
    /**
18
     * @return bool
19
     */
20 2
    public function canDisplay()
21
    {
22 2
        if (is_callable($this->rule)) {
23 1
            return (bool)call_user_func($this->rule);
24
        }
25
        
26 2
        return (bool)$this->rule;
27
    }
28
}