Passed
Branch v2-dev (5d4b18)
by Henri
01:19
created

Helper::inSave()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace HnrAzevedo\Router;
4
5
trait Helper
6
{
7
    protected array $routes = [];
8
    protected static Router $instance;
9
    protected string $host = '';
10
11
    public static function getInstance(): RouterInterface
12
    {
13
        self::$instance = (!isset(self::$instance)) ? new Router() : self::$instance;
14
        return self::$instance;
15
    }
16
17
    protected static function updateRoute(array $route, $key): RouterInterface
18
    {
19
        self::getInstance()->getRoutes()[$key] = $route;
20
        return self::getInstance();
21
    }
22
23
    public static function defineHost(string $host): Router
24
    {
25
        self::getInstance()->host = $host;
0 ignored issues
show
Bug introduced by
The property host is declared protected in HnrAzevedo\Router\Router and cannot be accessed from this context.
Loading history...
26
        return self::getInstance();
27
    }
28
29
    protected function inSave(): array
30
    {
31
        return end($this->routes);
32
    }
33
34
    protected function getHost(): string
35
    {
36
        return $this->host;
37
    }
38
39
    protected function getRoutes(): array
40
    {
41
        return $this->routes;
42
    }
43
44
    protected function setRoutes(array $routes): void
45
    {
46
        $this->routes =  $routes;
47
    }
48
49
}
50