Passed
Push — master ( c6d817...cca966 )
by Caen
03:03 queued 12s
created

AdminPage::getRouteKey()   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 Hyde\Admin;
4
5
use Desilva\Microserve\Request;
6
use Hyde\Framework\Contracts\PageContract;
7
use Hyde\Framework\Models\Pages\BladePage;
8
9
final class AdminPage extends BladePage implements PageContract
10
{
11
    /** Not yet implemented, but could be used by the framework to ignore this when compiling */
12
    protected static bool $compilable = false;
13
14
    public string $route;
15
16
    /**
17
     * @inheritDoc
18
     */
19
    public function __construct(string $view)
20
    {
21
        parent::__construct($view);
22
23
        $this->route = $this->request()?->get('route', 'dashboard') ?? 'dashboard';
24
    }
25
26
    public function getRouteKey(): string
27
    {
28
        return 'admin';
29
    }
30
31
    public function navigationMenuTitle(): string
32
    {
33
        return 'Admin Panel';
34
    }
35
36
    public function request(): ?Request
37
    {
38
        return isset($_SERVER['REQUEST_METHOD'])
39
            ? Request::capture()
40
            : null;
41
    }
42
43
    public function view(): string
44
    {
45
        $view = 'hyde-admin::pages.'.$this->route;
46
47
        return view()->exists($view) ? $view : 'hyde-admin::pages.404';
48
    }
49
}
50