Passed
Push — master ( b86a9b...818b3e )
by Thierry
02:35
created

DialogLibraryTrait::getSubdir()   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
 * DialogLibraryTrait.php
5
 *
6
 * Common functions for javascript dialog libraries.
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
 * @copyright 2016 Thierry Feuzeu <[email protected]>
11
 * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
12
 * @link https://github.com/jaxon-php/jaxon-dialogs
13
 */
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...
14
15
namespace Jaxon\App\Dialog\Library;
16
17
use Jaxon\Response\Response;
18
19
trait DialogLibraryTrait
0 ignored issues
show
Coding Style introduced by
Missing doc comment for trait DialogLibraryTrait
Loading history...
20
{
21
    /**
22
     * The dialog library helper
23
     *
24
     * @var DialogLibraryHelper
25
     */
26
    protected $xHelper;
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line(s) before first member var; 0 found
Loading history...
27
28
    /**
29
     * @var Response
30
     */
31
    protected $xResponse = null;
32
33
    /**
34
     * For MessageInterface, tells if the calls to the functions shall
35
     * add commands to the response or return the js code. By default, they add commands.
36
     *
37
     * @var bool
0 ignored issues
show
Bug introduced by
Expected "boolean" but found "bool" for @var tag in member variable comment
Loading history...
38
     */
39
    protected $bReturnCode = false;
40
41
    /**
42
     * Get the library name
43
     *
44
     * @return string
45
     */
46
    abstract public function getName(): string;
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
47
48
    /**
49
     * Get the helper
50
     *
51
     * @return DialogLibraryHelper
52
     */
53
    final public function helper(): DialogLibraryHelper
54
    {
55
        return $this->xHelper;
56
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
57
58
    /**
59
     * Set the response to attach the messages to.
60
     *
61
     * @param Response $xResponse    Whether to return the code
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
62
     *
63
     * @return void
64
     */
65
    final public function setResponse(Response $xResponse)
66
    {
67
        $this->xResponse = $xResponse;
68
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
69
70
    /**
71
     * Get the <Jaxon\Response\Response> object
72
     *
73
     * @return Response|null
74
     */
75
    final protected function response(): ?Response
76
    {
77
        return $this->xResponse;
78
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
79
80
    /**
81
     * @param bool $bReturnCode
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
82
     *
83
     * @return void
84
     */
85
    final public function setReturnCode(bool $bReturnCode)
86
    {
87
        $this->bReturnCode = $bReturnCode;
88
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
89
90
    /**
91
     * Check if the library should return the js code or run it in the browser.
92
     *
93
     * @return bool
94
     */
95
    final protected function returnCode(): bool
96
    {
97
        return $this->bReturnCode;
98
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
99
100
    /**
101
     * Add a client side plugin command to the response object
102
     *
103
     * @param array $aAttributes The attributes of the command
104
     * @param mixed $xData The data to be added to the command
0 ignored issues
show
Coding Style introduced by
Expected 7 spaces after parameter name; 1 found
Loading history...
105
     *
106
     * @return void
107
     */
108
    final public function addCommand(array $aAttributes, $xData)
109
    {
110
        // This is usually the response plugin name. We set the library name instead.
111
        $aAttributes['plg'] = $this->getName();
112
        $this->xResponse->addCommand($aAttributes, $xData);
113
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
114
115
    /**
116
     * Get the library base URI
117
     *
118
     * @return string
119
     */
120
    public function getUri(): string
121
    {
122
        return 'https://cdn.jaxon-php.org/libs';
123
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
124
125
    /**
126
     * Get the library subdir for the URI
127
     *
128
     * @return string
129
     */
130
    public function getSubdir(): string
131
    {
132
        return '';
133
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
134
135
    /**
136
     * Get the library version for the URI
137
     *
138
     * @return string
139
     */
140
    public function getVersion(): string
141
    {
142
        return '';
143
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
144
145
    /**
146
     * Get the CSS header code and file includes
147
     *
148
     * @return string
149
     */
150
    public function getJs(): string
151
    {
152
        return '';
153
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
154
155
    /**
156
     * Get the javascript header code and file includes
157
     *
158
     * @return string
159
     */
160
    public function getCss(): string
161
    {
162
        return '';
163
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
164
165
    /**
166
     * Get the javascript code to be printed into the page
167
     *
168
     * @return string
169
     */
170
    public function getScript(): string
171
    {
172
        return '';
173
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
174
175
    /**
176
     * Get the javascript code to be executed on page load
177
     *
178
     * @return string
179
     */
180
    public function getReadyScript(): string
181
    {
182
        return '';
183
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
184
}
185