Passed
Push — master ( c3dc3d...4d8459 )
by Caen
03:08 queued 12s
created

AdminPage   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 39
rs 10
c 0
b 0
f 0
wmc 7

5 Methods

Rating   Name   Duplication   Size   Complexity  
A navigationMenuTitle() 0 3 1
A __construct() 0 5 1
A view() 0 5 2
A request() 0 5 2
A getCurrentPagePath() 0 3 1
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 getCurrentPagePath(): 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