Test Failed
Push — develop ( 92c10d...ff12cf )
by Daniel
05:05
created

ChildRouteTrait   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 6
eloc 13
dl 0
loc 41
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getParentRoute() 0 9 3
A isNested() 0 3 1
A setParentRoute() 0 4 1
A setNested() 0 4 1
1
<?php
2
3
namespace Silverback\ApiComponentBundle\Entity\Route;
4
5
use Doctrine\ORM\Mapping as ORM;
6
7
trait ChildRouteTrait
8
{
9
    /**
10
     * @ORM\ManyToOne(targetEntity="Silverback\ApiComponentBundle\Entity\Route\Route")
11
     * @ORM\JoinColumn(nullable=true, referencedColumnName="id", onDelete="SET NULL")
12
     * @var Route|null
13
     */
14
    protected $parentRoute;
15
16
    /**
17
     * @ORM\Column(type="boolean", options={"default":"0"})
18
     * @var boolean
19
     */
20
    protected $nested = false;
21
22
    public function isNested(): bool
23
    {
24
        return $this->nested;
25
    }
26
27
    public function setNested(bool $nested)
28
    {
29
        $this->nested = $nested;
30
        return $this;
31
    }
32
33
    public function setParentRoute(?Route $parentRoute)
34
    {
35
        $this->parentRoute = $parentRoute;
36
        return $this;
37
    }
38
39
    public function getParentRoute(): ?Route
40
    {
41
        if ($this->parentRoute) {
42
            return $this->parentRoute;
43
        }
44
        if ($this->nested) {
45
            return parent::getParentRoute();
46
        }
47
        return null;
48
    }
49
}
50