Passed
Pull Request — master (#84)
by
unknown
12:21
created

Predicates::isChild()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Staudenmeir\LaravelAdjacencyList\Eloquent;
4
5
trait Predicates
6
{
7
    /**
8
     * Determine if the model has a parent
9
     *
10
     * @return bool
11
     */
12
    public function hasParent()
13
    {
14
        return $this->{$this->getParentKeyName()} !== null;
0 ignored issues
show
Bug introduced by
It seems like getParentKeyName() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

14
        return $this->{$this->/** @scrutinizer ignore-call */ getParentKeyName()} !== null;
Loading history...
15
    }
16
17
    /**
18
     * Determine if the model is a child
19
     *
20
     * @return bool
21
     */
22
    public function isChild()
23
    {
24
        return $this->hasParent();
25
    }
26
27
    /**
28
     * Determine if the model is root
29
     *
30
     * @return bool
31
     */
32
    public function isRoot()
33
    {
34
        return $this->{$this->getParentKeyName()} === null;
35
    }
36
}