Passed
Branch v2-dev (d50d65)
by Henri
01:22
created

Helper::getPrefix()   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
    private string $prefix = '';
11
    protected ?string $group = null;
12
13
    public static function getInstance(): RouterInterface
14
    {
15
        self::$instance = (!isset(self::$instance)) ? new Router() : self::$instance;
16
        return self::$instance;
17
    }
18
19
    protected static function updateRoute(array $route, $key): RouterInterface
20
    {
21
        self::getInstance()->getRoutes()[$key] = $route;
22
        return self::getInstance();
23
    }
24
25
    public static function defineHost(string $host): Router
26
    {
27
        self::getInstance()->setHost($host);
28
        return self::getInstance();
29
    }
30
31
    protected function inSave(): array
32
    {
33
        return end($this->routes);
34
    }
35
36
    protected function setHost(string $host): void
37
    {
38
        $this->host = $host;
39
    }
40
41
    protected function getHost(): string
42
    {
43
        return $this->host;
44
    }
45
46
    protected function getRoutes(): array
47
    {
48
        return $this->routes;
49
    }
50
51
    protected function setRoutes(array $routes): void
52
    {
53
        $this->routes =  $routes;
54
    }
55
56
    protected function getGroup(): ?string
57
    {
58
        return $this->group;
59
    }
60
61
    protected function setGroup(?string $group): void
62
    {
63
        $this->group = $group;
64
    }
65
66
    protected function getPrefix(): ?string
67
    {
68
        return $this->prefix;
69
    }
70
71
    protected function setPrefix(string $prefix): void
72
    {
73
        $this->prefix = $prefix;
74
    }
75
}
76