Passed
Branch v2-dev (b00ce0)
by Henri
01:15
created

Helper::setGroup()   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 1
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()->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...
28
        return self::getInstance();
29
    }
30
31
    protected function inSave(): array
32
    {
33
        return end($this->routes);
34
    }
35
36
    protected function getHost(): string
37
    {
38
        return $this->host;
39
    }
40
41
    protected function getRoutes(): array
42
    {
43
        return $this->routes;
44
    }
45
46
    protected function setRoutes(array $routes): void
47
    {
48
        $this->routes =  $routes;
49
    }
50
51
    protected function getGroup(): ?string
52
    {
53
        return $this->group;
54
    }
55
56
    protected function setGroup(?string $group): void
57
    {
58
        $this->group = $group;
59
    }
60
61
    protected function getPrefix(): ?string
62
    {
63
        return $this->prefix;
64
    }
65
66
    protected function setPrefix(string $prefix): void
67
    {
68
        $this->prefix = $prefix;
69
    }
70
}
71