OwnerTrait   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 1
Metric Value
eloc 16
dl 0
loc 36
rs 10
c 3
b 0
f 1
wmc 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A unsetRoute() 0 6 1
A loadIn() 0 5 1
A runIn() 0 9 2
A hasCurrentRoute() 0 4 2
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace HnrAzevedo\Router;
6
7
trait OwnerTrait
8
{
9
    use Helper,
10
        CheckTrait;
11
12
    public function loadIn(string $name)
13
    {
14
        $this->hasRouteName($name);
15
        $this->loaded = true;
16
        return $this;
17
    }
18
19
    public function runIn(string $name)
20
    {
21
        $this->hasRouteName($name);
22
23
        if(!$this->loaded()) {
24
            $this->loadIn($name);
25
        }
26
        
27
        return $this;
28
    }
29
30
    public function hasCurrentRoute(): void
31
    {
32
        if(!isset($this->currentRoute)) {
33
            throw new \RuntimeException('Route not yet loaded');
34
        }
35
    }
36
37
    public function unsetRoute($key)
38
    {
39
        $routes = $this->getRoutes();
40
        unset($routes[$key]);
41
        $this->setRoutes($routes);
42
        return $this;
43
    }
44
45
}
46