Passed
Push — master ( bcb1ec...700d1f )
by Paul
02:53
created

Module::render()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace GeminiLabs\BlackBar\Modules;
4
5
use GeminiLabs\BlackBar\Application;
6
7
abstract class Module
8
{
9
    /**
10
     * @var Application
11
     */
12
    protected $app;
13
    /**
14
     * @var array
15
     */
16
    protected $entries;
17
18
    public function __construct(Application $app)
19
    {
20
        $this->app = $app;
21
        $this->entries = [];
22
    }
23
24
    public function classes(): string
25
    {
26
        return $this->id();
27
    }
28
29
    abstract public function entries(): array;
30
31
    public function hasEntries(): bool
32
    {
33
        return !empty($this->entries);
34
    }
35
36
    public function id(): string
37
    {
38
        return sprintf('glbb-%s', $this->slug());
39
    }
40
41
    public function isVisible(): bool
42
    {
43
        return true;
44
    }
45
46
    abstract public function label(): string;
47
48
    public function render(): void
49
    {
50
        $this->app->render('panels/'.$this->slug(), ['module' => $this]);
51
    }
52
53
    public function slug(): string
54
    {
55
        return strtolower((new \ReflectionClass($this))->getShortName());
56
    }
57
}
58