GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( a9bc98...b864c9 )
by butschster
10:50
created

VisibleCondition   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 31
c 0
b 0
f 0
rs 10
wmc 3
lcom 1
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A isVisible() 0 8 2
A setVisibilityCondition() 0 6 1
1
<?php
2
3
namespace SleepingOwl\Admin\Traits;
4
5
use Closure;
6
7
trait VisibleCondition
8
{
9
    /**
10
     * @var Closure|null
11
     */
12
    protected $visibleCondition;
13
14
    /**
15
     * @return bool
16
     */
17
    public function isVisible()
18
    {
19
        if (is_callable($this->visibleCondition)) {
20
            return (bool) call_user_func($this->visibleCondition, $this->getModel());
0 ignored issues
show
Bug introduced by
It seems like getModel() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
21
        }
22
23
        return true;
24
    }
25
26
    /**
27
     * @param Closure $condition
28
     *
29
     * @return $this
30
     */
31
    public function setVisibilityCondition(Closure $condition)
32
    {
33
        $this->visibleCondition = $condition;
34
35
        return $this;
36
    }
37
}
38