Passed
Push — main ( 28b00c...2eb7a0 )
by Thierry
20:47 queued 09:28
created

LoggingPackage::getReadyScript()   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
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Lagdo\DbAdmin;
4
5
use Jaxon\Plugin\AbstractPackage;
6
use Lagdo\DbAdmin\Ajax\Log\Commands;
7
use Lagdo\DbAdmin\Ajax\Log\Wrapper;
8
9
use function realpath;
10
use function Jaxon\cl;
11
use function Jaxon\rq;
12
13
/**
14
 * Jaxon DbAdmin logging package
15
 */
16
class LoggingPackage extends AbstractPackage
17
{
18
    /**
19
     * Get the path to the config file
20
     *
21
     * @return string|array
22
     */
23
    public static function config(): string
24
    {
25
        return realpath(__DIR__ . '/../config/logging.php');
26
    }
27
28
    /**
29
     * Get a given server options
30
     *
31
     * @return array
32
     */
33
    public function getServerOptions(): array
34
    {
35
        return $this->getOption('database', []);
36
    }
37
38
    /**
39
     * Get the driver of a given server
40
     *
41
     * @return string
42
     */
43
    public function getServerDriver(): string
44
    {
45
        return $this->getOption('database.driver', '');
46
    }
47
48
    /**
49
     * Get the HTML tags to include CSS code and files into the page
50
     *
51
     * The code must be enclosed in the appropriate HTML tags.
52
     *
53
     * @return string
54
     */
55
    public function getCss(): string
56
    {
57
        return $this->view()->render('dbadmin::codes::css.html') . "\n<style>\n" .
58
            $this->view()->render('dbadmin::codes::styles.css') . "\n</style>\n";
59
    }
60
61
    /**
62
     * Get the HTML tags to include javascript code and files into the page
63
     *
64
     * The code must be enclosed in the appropriate HTML tags.
65
     *
66
     * @return string
67
     */
68
    public function getJs(): string
69
    {
70
        return $this->view()->render('dbadmin::codes::js.html');
71
    }
72
73
    /**
74
     * Get the javascript code to include into the page
75
     *
76
     * The code must NOT be enclosed in HTML tags.
77
     *
78
     * @return string
79
     */
80
    public function getScript(): string
81
    {
82
        return $this->view()->render('dbadmin::codes::script.js');
83
    }
84
85
    /**
86
     * Get the javascript code to include into the page
87
     *
88
     * The code must NOT be enclosed in HTML tags.
89
     *
90
     * @return string
91
     */
92
    public function getReadyScript(): string
93
    {
94
        return rq(Commands::class)->page();
95
    }
96
97
    /**
98
     * Get the HTML code of the package home page
99
     *
100
     * @return string
101
     */
102
    public function getHtml(): string
103
    {
104
        return cl(Wrapper::class)->html();
105
    }
106
}
107