Passed
Push — master ( dc0218...f79a4b )
by Thierry
02:43
created

Package::getOptions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * Generator.php - Code generator interface
5
 *
6
 * Any class generating css or js code must implement this interface.
7
 *
8
 * @package jaxon-core
0 ignored issues
show
Coding Style introduced by
Package name "jaxon-core" is not valid; consider "Jaxoncore" instead
Loading history...
9
 * @author Thierry Feuzeu <[email protected]>
10
 * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
11
 * @link https://github.com/jaxon-php/jaxon-core
12
 */
0 ignored issues
show
Coding Style introduced by
PHP version not specified
Loading history...
Coding Style introduced by
Missing @category tag in file comment
Loading history...
13
14
namespace Jaxon\Plugin;
15
16
use Jaxon\Ui\View\Renderer;
17
use Jaxon\Utils\Config\Config;
18
19
abstract class Package implements Code\Contracts\Generator
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class Package
Loading history...
20
{
21
    /**
22
     * The configuration options of the package
23
     *
24
     * @var Config
25
     */
26
    protected $xPkgConfig;
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line(s) before first member var; 0 found
Loading history...
27
28
    /**
29
     * The view renderer
30
     *
31
     * @var Renderer
32
     */
33
    protected $xRenderer;
34
35
    /**
36
     * Whether to include the getReadyScript() in the generated code.
37
     *
38
     * @var bool
0 ignored issues
show
Bug introduced by
Expected "boolean" but found "bool" for @var tag in member variable comment
Loading history...
39
     */
40
    protected $bReadyEnabled = false;
41
42
    /**
43
     * Get the package options in a Config object.
44
     *
45
     * @return Config
46
     */
47
    public function getConfig(): Config
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
48
    {
49
        return $this->xPkgConfig;
50
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
51
52
    /**
53
     * Get the value of a given package option
54
     *
55
     * @param string $sOption    The option name
0 ignored issues
show
Coding Style introduced by
Expected 2 spaces after parameter name; 4 found
Loading history...
56
     * @param mixed $xDefault    The default value
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
Coding Style introduced by
Expected 2 spaces after parameter type; 1 found
Loading history...
57
     *
58
     * @return mixed
59
     */
60
    public function getOption(string $sOption, $xDefault = null)
61
    {
62
        return $this->xPkgConfig->getOption($sOption, $xDefault);
63
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
64
65
    /**
66
     * Get the view renderer
67
     *
68
     * @return Renderer
69
     */
70
    public function view(): Renderer
71
    {
72
        return $this->xRenderer;
73
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
74
75
    /**
76
     * Get the path to the config file
77
     *
78
     * @return string
79
     */
80
    abstract public static function getConfigFile(): string;
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
81
82
    /**
83
     * Include the getReadyScript() in the generated code.
84
     *
85
     * @return void
86
     */
87
    public function ready()
88
    {
89
        $this->bReadyEnabled = true;
90
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
91
92
    /**
93
     * @inheritDoc
94
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
95
    public function readyEnabled(): bool
96
    {
97
        return $this->bReadyEnabled;
98
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
99
100
    /**
101
     * @inheritDoc
102
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
103
    public final function readyInlined(): bool
104
    {
105
        // For packages, the getReadyScript() is never exported to external files.
106
        return true;
107
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
108
109
    /**
110
     * @inheritDoc
111
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
112
    public final function getHash(): string
113
    {
114
        // Packages do not generate hash on their own. So we make this method final.
115
        return '';
116
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
117
118
    /**
119
     * @inheritDoc
120
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
121
    public function getCss(): string
122
    {
123
        return '';
124
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
125
126
    /**
127
     * @inheritDoc
128
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
129
    public function getJs(): string
130
    {
131
        return '';
132
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
133
134
    /**
135
     * @inheritDoc
136
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
137
    public function getScript(): string
138
    {
139
        return '';
140
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
141
142
    /**
143
     * Get the HTML code of the package home page
144
     *
145
     * @return string
146
     */
147
    abstract public function getHtml(): string;
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
148
149
    /**
150
     * Get the HTML code of the package home page
151
     *
152
     * This method is an alias for getHtml().
153
     *
154
     * @return string
155
     */
156
    public function html(): string
157
    {
158
        return $this->getHtml();
159
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
160
}
161