Passed
Push — master ( bf2aee...a6dc35 )
by Thierry
02:22
created

Jaxon::getDefaultOptions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 33
Code Lines 29

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 29
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 33
rs 9.456

2 Methods

Rating   Name   Duplication   Size   Complexity  
A Jaxon::setOption() 0 3 1
A Jaxon::logger() 0 3 1
1
<?php
2
3
/**
4
 * Jaxon.php - Jaxon class
5
 *
6
 * The Jaxon class uses a modular plug-in system to facilitate the processing
7
 * of special Ajax requests made by a PHP page.
8
 * It generates Javascript that the page must include in order to make requests.
9
 * It handles the output of response commands (see <Jaxon\Response\Response>).
10
 * Many flags and settings can be adjusted to effect the behavior of the Jaxon class
11
 * as well as the client-side javascript.
12
 *
13
 * @package jaxon-core
0 ignored issues
show
Coding Style introduced by
Package name "jaxon-core" is not valid; consider "Jaxoncore" instead
Loading history...
14
 * @author Jared White
0 ignored issues
show
Coding Style introduced by
Content of the @author tag must be in the form "Display Name <[email protected]>"
Loading history...
15
 * @author J. Max Wilson
0 ignored issues
show
Coding Style introduced by
Content of the @author tag must be in the form "Display Name <[email protected]>"
Loading history...
16
 * @author Joseph Woolley
0 ignored issues
show
Coding Style introduced by
Content of the @author tag must be in the form "Display Name <[email protected]>"
Loading history...
17
 * @author Steffen Konerow
0 ignored issues
show
Coding Style introduced by
Content of the @author tag must be in the form "Display Name <[email protected]>"
Loading history...
18
 * @author Thierry Feuzeu <[email protected]>
19
 * @copyright Copyright (c) 2005-2007 by Jared White & J. Max Wilson
0 ignored issues
show
Coding Style introduced by
@copyright tag must contain a year and the name of the copyright holder
Loading history...
20
 * @copyright Copyright (c) 2008-2010 by Joseph Woolley, Steffen Konerow, Jared White  & J. Max Wilson
0 ignored issues
show
Coding Style introduced by
@copyright tag must contain a year and the name of the copyright holder
Loading history...
21
 * @copyright 2016 Thierry Feuzeu <[email protected]>
22
 * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
23
 * @link https://github.com/jaxon-php/jaxon-core
24
 */
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...
25
26
namespace Jaxon;
27
28
use Jaxon\App\App;
29
use Jaxon\Config\ConfigManager;
30
use Jaxon\Di\Container;
31
use Jaxon\Exception\RequestException;
32
use Jaxon\Exception\SetupException;
33
use Jaxon\Plugin\Code\CodeGenerator;
34
use Jaxon\Plugin\Manager\PluginManager;
35
use Jaxon\Plugin\Package;
36
use Jaxon\Plugin\ResponsePlugin;
37
use Jaxon\Request\Factory\Factory;
38
use Jaxon\Request\Factory\RequestFactory;
39
use Jaxon\Request\Handler\CallbackManager;
40
use Jaxon\Request\Handler\RequestHandler;
41
use Jaxon\Request\Handler\UploadHandler;
42
use Jaxon\Request\Plugin\CallableClass\CallableRegistry;
43
use Jaxon\Response\AbstractResponse;
44
use Jaxon\Response\Response;
45
use Jaxon\Response\ResponseManager;
46
use Jaxon\Session\SessionInterface;
47
use Jaxon\Ui\View\ViewRenderer;
48
use Jaxon\Utils\Config\Config;
49
use Jaxon\Utils\Http\UriException;
50
use Jaxon\Utils\Template\TemplateEngine;
0 ignored issues
show
Bug introduced by
The type Jaxon\Utils\Template\TemplateEngine was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
51
use Jaxon\Utils\Translation\Translator;
52
53
use Psr\Log\LoggerAwareInterface;
54
use Psr\Log\LoggerAwareTrait;
55
use Psr\Log\LoggerInterface;
56
use Psr\Log\NullLogger;
57
58
use function trim;
59
60
class Jaxon implements LoggerAwareInterface
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class Jaxon
Loading history...
61
{
62
    use LoggerAwareTrait;
63
64
    /**
65
     * Package version number
66
     *
67
     * @const string
68
     */
69
    const VERSION = 'Jaxon 4.0.0-dev';
70
71
    /*
72
     * Request plugins
73
     */
0 ignored issues
show
Coding Style introduced by
Empty line required after block comment
Loading history...
74
    const CALLABLE_CLASS = 'CallableClass';
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 4 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
75
    const CALLABLE_DIR = 'CallableDir';
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 6 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
76
    const CALLABLE_FUNCTION = 'CallableFunction';
77
78
    /**
79
     * A static instance on this class
80
     *
81
     * @var Jaxon
82
     */
83
    private static $xInstance = null;
84
85
    /**
86
     * The DI container
87
     *
88
     * @var Container
89
     */
90
    private static $xContainer = null;
91
92
    /**
93
     * @var Translator
94
     */
95
    protected $xTranslator;
96
97
    /**
98
     * @var ConfigManager
99
     */
100
    protected $xConfigManager;
101
102
    /**
103
     * @var PluginManager
104
     */
105
    protected $xPluginManager;
106
107
    /**
108
     * @var CodeGenerator
109
     */
110
    protected $xCodeGenerator;
111
112
    /**
113
     * @var CallableRegistry
114
     */
115
    protected $xClassRegistry;
116
117
    /**
118
     * @var RequestHandler
119
     */
120
    protected $xRequestHandler;
121
122
    /**
123
     * @var ResponseManager
124
     */
125
    protected $xResponseManager;
126
127
    /**
128
     * @return void
129
     */
130
    private static function initInstance()
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
131
    {
132
        // Set the attributes from the container
133
        self::$xInstance->xTranslator = self::$xContainer->g(Translator::class);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 6 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
134
        self::$xInstance->xConfigManager = self::$xContainer->g(ConfigManager::class);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
135
        self::$xInstance->xPluginManager = self::$xContainer->g(PluginManager::class);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
136
        self::$xInstance->xCodeGenerator = self::$xContainer->g(CodeGenerator::class);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
137
        self::$xInstance->xClassRegistry = self::$xContainer->g(CallableRegistry::class);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
138
        self::$xInstance->xRequestHandler = self::$xContainer->g(RequestHandler::class);
139
        self::$xInstance->xResponseManager = self::$xContainer->g(ResponseManager::class);
140
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
141
142
    /**
143
     * Get the static instance
144
     *
145
     * @return Jaxon
146
     */
147
    public static function getInstance(): ?Jaxon
148
    {
149
        if(self::$xInstance === null)
150
        {
151
            self::$xInstance = new Jaxon();
152
            self::$xContainer = new Container(self::$xInstance);
153
            self::initInstance();
154
        }
155
        return self::$xInstance;
156
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
157
158
    /**
159
     * The constructor
160
     */
161
    private function __construct()
162
    {
163
        // Set the default logger
164
        $this->setLogger(new NullLogger());
165
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
166
167
    /**
168
     * The current Jaxon version
169
     *
170
     * @return string
171
     */
172
    public function getVersion(): string
173
    {
174
        return self::VERSION;
175
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
176
177
    /**
178
     * Get the DI container
179
     *
180
     * @return Container
181
     */
182
    public function di(): ?Container
183
    {
184
        return self::$xContainer;
185
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
186
187
    /**
188
     * Get the logger
189
     *
190
     * @return LoggerInterface
191
     */
192
    public function logger(): LoggerInterface
193
    {
194
        return $this->logger;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->logger could return the type null which is incompatible with the type-hinted return Psr\Log\LoggerInterface. Consider adding an additional type-check to rule them out.
Loading history...
195
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
196
197
    /**
198
     * Set the value of a config option
199
     *
200
     * @param string $sName    The option name
0 ignored issues
show
Coding Style introduced by
Expected 2 spaces after parameter name; 4 found
Loading history...
201
     * @param mixed $sValue    The option value
0 ignored issues
show
Coding Style introduced by
Expected 2 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
202
     *
203
     * @return void
204
     */
205
    public function setOption(string $sName, $sValue)
206
    {
207
        $this->xConfigManager->setOption($sName, $sValue);
208
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
209
210
    /**
211
     * Get the value of a config option
212
     *
213
     * @param string $sName    The option name
0 ignored issues
show
Coding Style introduced by
Expected 5 spaces after parameter type; 1 found
Loading history...
214
     * @param mixed|null $xDefault    The default value, to be returned if the option is not defined
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
215
     *
216
     * @return mixed        The option value, or null if the option is unknown
217
     */
218
    public function getOption(string $sName, $xDefault = null)
219
    {
220
        return $this->xConfigManager->getOption($sName, $xDefault);
221
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
222
223
    /**
224
     * Check the presence of a config option
225
     *
226
     * @param string $sName    The option name
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
227
     *
228
     * @return bool        True if the option exists, and false if not
229
     */
230
    public function hasOption(string $sName): bool
231
    {
232
        return $this->xConfigManager->hasOption($sName);
233
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
234
235
    /**
236
     * Read the options from the file, if provided, and return the config
237
     *
238
     * @param string $sConfigFile The full path to the config file
0 ignored issues
show
Coding Style introduced by
Expected 4 spaces after parameter name; 1 found
Loading history...
239
     * @param string $sConfigSection The section of the config file to be loaded
240
     *
241
     * @return Config
242
     * @throws SetupException
243
     */
244
    public function config(string $sConfigFile = '', string $sConfigSection = ''): Config
245
    {
246
        if(!empty(($sConfigFile = trim($sConfigFile))))
0 ignored issues
show
Coding Style introduced by
Variable assignment found within a condition. Did you mean to do a comparison ?
Loading history...
247
        {
248
            $this->xConfigManager->load($sConfigFile, trim($sConfigSection));
249
        }
250
        return $this->xConfigManager->getConfig();
251
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
252
253
    /**
254
     * Get a translated string
255
     *
256
     * @param string $sText    The key of the translated string
0 ignored issues
show
Coding Style introduced by
Expected 9 spaces after parameter name; 4 found
Loading history...
257
     * @param array $aPlaceHolders    The placeholders of the translated string
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...
258
     * @param string $sLanguage    The language of the translated string
0 ignored issues
show
Coding Style introduced by
Expected 5 spaces after parameter name; 4 found
Loading history...
259
     *
260
     * @return string
261
     */
262
    public function trans(string $sText, array $aPlaceHolders = [], string $sLanguage = ''): string
263
    {
264
        return $this->xTranslator->trans($sText, $aPlaceHolders, $sLanguage);
265
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
266
267
    /**
268
     * Get the Global Response object
269
     *
270
     * @return AbstractResponse
271
     */
272
    public function getResponse(): AbstractResponse
273
    {
274
        if(($xResponse = $this->xResponseManager->getResponse()))
0 ignored issues
show
Coding Style introduced by
Variable assignment found within a condition. Did you mean to do a comparison ?
Loading history...
275
        {
276
            return $xResponse;
277
        }
278
        return $this->di()->getResponse();
279
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
280
281
    /**
282
     * Create a new Jaxon response object
283
     *
284
     * @return Response
285
     */
286
    public function newResponse(): Response
287
    {
288
        return $this->di()->newResponse();
289
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
290
291
    /**
292
     * Register a plugin
293
     *
294
     * Below is a table for priorities and their description:
295
     * - 0 to 999: Plugins that are part of or extensions to the jaxon core
296
     * - 1000 to 8999: User created plugins, typically, these plugins don't care about order
297
     * - 9000 to 9999: Plugins that generally need to be last or near the end of the plugin list
298
     *
299
     * @param string $sClassName    The plugin class
0 ignored issues
show
Coding Style introduced by
Expected 2 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Expected 2 spaces after parameter name; 4 found
Loading history...
300
     * @param string $sPluginName    The plugin name
0 ignored issues
show
Coding Style introduced by
Expected 2 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
301
     * @param integer $nPriority    The plugin priority, used to order the plugins
0 ignored issues
show
Coding Style introduced by
Expected 3 spaces after parameter name; 4 found
Loading history...
302
     *
303
     * @return void
304
     * @throws SetupException
305
     */
306
    public function registerPlugin(string $sClassName, string $sPluginName, int $nPriority = 1000)
307
    {
308
        $this->xPluginManager->registerPlugin($sClassName, $sPluginName, $nPriority);
309
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
310
311
    /**
312
     * Register a package
313
     *
314
     * @param string $sClassName    The package class
0 ignored issues
show
Coding Style introduced by
Expected 2 spaces after parameter name; 4 found
Loading history...
315
     * @param array $xPkgOptions    The user provided package options
0 ignored issues
show
Coding Style introduced by
Expected 2 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
316
     *
317
     * @return void
318
     * @throws SetupException
319
     */
320
    public function registerPackage(string $sClassName, array $xPkgOptions = [])
321
    {
322
        $this->xPluginManager->registerPackage($sClassName, $xPkgOptions);
323
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
324
325
    /**
326
     * Register request handlers, including functions, callable classes and directories.
327
     *
328
     * @param string $sType    The type of request handler being registered
0 ignored issues
show
Coding Style introduced by
Expected 7 spaces after parameter type; 1 found
Loading history...
329
     *        Options include:
0 ignored issues
show
Coding Style introduced by
Parameter comment not aligned correctly; expected 25 spaces but found 8
Loading history...
330
     *        - Jaxon::CALLABLE_FUNCTION: a function declared at global scope
0 ignored issues
show
Coding Style introduced by
Parameter comment not aligned correctly; expected 25 spaces but found 8
Loading history...
331
     *        - Jaxon::CALLABLE_CLASS: a class who's methods are to be registered
0 ignored issues
show
Coding Style introduced by
Parameter comment not aligned correctly; expected 25 spaces but found 8
Loading history...
332
     *        - Jaxon::CALLABLE_DIR: a directory containing classes to be registered
0 ignored issues
show
Coding Style introduced by
Parameter comment not aligned correctly; expected 25 spaces but found 8
Loading history...
333
     * @param string $sName
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 7 spaces after parameter type; 1 found
Loading history...
334
     *        When registering a function, this is the name of the function
335
     *        When registering a callable class, this is the class name
336
     *        When registering a callable directory, this is the full path to the directory
337
     * @param array|string $xOptions    The related options
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
338
     *
339
     * @return void
340
     * @throws SetupException
341
     */
342
    public function register(string $sType, string $sName, $xOptions = [])
343
    {
344
        $this->xPluginManager->registerCallable($sType, $sName, $xOptions);
345
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
346
347
    /**
348
     * Get an instance of a registered class
349
     *
350
     * @param string $sClassName The class name
351
     *
352
     * @return null|object
353
     * @throws SetupException
354
     */
355
    public function instance(string $sClassName)
356
    {
357
        $xCallable = $this->xClassRegistry->getCallableObject($sClassName);
358
        return ($xCallable) ? $xCallable->getRegisteredObject() : null;
0 ignored issues
show
introduced by
$xCallable is of type Jaxon\Request\Plugin\CallableClass\CallableObject, thus it always evaluated to true.
Loading history...
359
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
360
361
    /**
362
     * Get the factory
363
     *
364
     * @return Factory
365
     */
366
    public function factory(): Factory
367
    {
368
        return $this->di()->g(Factory::class);
369
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
370
371
    /**
372
     * Get a request to a registered class
373
     *
374
     * @param string $sClassName The class name
375
     *
376
     * @return RequestFactory|null
377
     * @throws SetupException
378
     */
379
    public function request(string $sClassName = ''): ?RequestFactory
380
    {
381
        return $this->factory()->request($sClassName);
382
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
383
384
    /**
385
     * Returns the Jaxon Javascript header and wrapper code to be printed into the page
386
     *
387
     * The javascript code returned by this function is dependent on the plugins
388
     * that are included and the functions and classes that are registered.
389
     *
390
     * @param bool $bIncludeJs    Also get the JS files
0 ignored issues
show
Coding Style introduced by
Expected 2 spaces after parameter name; 4 found
Loading history...
391
     * @param bool $bIncludeCss    Also get the CSS files
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
392
     *
393
     * @return string
394
     * @throws UriException
395
     */
396
    public function getScript(bool $bIncludeJs = false, bool $bIncludeCss = false): string
397
    {
398
        return $this->xCodeGenerator->getScript($bIncludeJs, $bIncludeCss);
399
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
400
401
    /**
402
     * Print the jaxon Javascript header and wrapper code into your page
403
     *
404
     * The javascript code returned by this function is dependent on the plugins
405
     * that are included and the functions and classes that are registered.
406
     *
407
     * @param bool $bIncludeJs    Also print the JS files
0 ignored issues
show
Coding Style introduced by
Expected 2 spaces after parameter name; 4 found
Loading history...
408
     * @param bool $bIncludeCss    Also print the CSS files
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
409
     *
410
     * @return void
411
     * @throws UriException
412
     */
413
    public function printScript(bool $bIncludeJs = false, bool $bIncludeCss = false)
414
    {
415
        print $this->getScript($bIncludeJs, $bIncludeCss);
416
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
417
418
    /**
419
     * Return the javascript header code and file includes
420
     *
421
     * @return string
422
     */
423
    public function getJs(): string
424
    {
425
        return $this->xCodeGenerator->getJs();
426
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
427
428
    /**
429
     * Return the CSS header code and file includes
430
     *
431
     * @return string
432
     */
433
    public function getCss(): string
434
    {
435
        return $this->xCodeGenerator->getCss();
436
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
437
438
    /**
439
     * Determine if a call is a jaxon request or a page load request
440
     *
441
     * @return bool
442
     */
443
    public function canProcessRequest(): bool
444
    {
445
        return $this->xRequestHandler->canProcessRequest();
446
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
447
448
    /**
449
     * If this is a jaxon request, call the requested PHP function, build the response and send it back to the browser
450
     *
451
     * This is the main server side engine for Jaxon.
452
     * It handles all the incoming requests, including the firing of events and handling of the response.
453
     * If your RequestURI is the same as your web page, then this function should be called before ANY
454
     * headers or HTML is output from your script.
455
     *
456
     * This function may exit after the request is processed, if the 'core.process.exit' option is set to true.
457
     *
458
     * @return void
459
     *
460
     * @throws RequestException
461
     * @throws SetupException
462
     * @see <Jaxon\Jaxon->canProcessRequest>
463
     */
464
    public function processRequest()
465
    {
466
        $this->xRequestHandler->processRequest();
467
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
468
469
    /**
470
     * Get a registered response plugin
471
     *
472
     * @param string $sName    The name of the plugin
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
473
     *
474
     * @return ResponsePlugin|null
475
     */
476
    public function plugin(string $sName): ?ResponsePlugin
477
    {
478
        return $this->xPluginManager->getResponsePlugin($sName);
479
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
480
481
    /**
482
     * Get a package instance
483
     *
484
     * @param string $sClassName    The package class name
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
485
     *
486
     * @return Package|null
487
     */
488
    public function package(string $sClassName): ?Package
489
    {
490
        return $this->xPluginManager->getPackage($sClassName);
491
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
492
493
    /**
494
     * Get the upload plugin
495
     *
496
     * @return UploadHandler|null
497
     */
498
    public function upload(): ?UploadHandler
499
    {
500
        return $this->di()->getUploadHandler();
501
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
502
503
    /**
504
     * Get the request callback manager
505
     *
506
     * @return CallbackManager
507
     */
508
    public function callback(): CallbackManager
509
    {
510
        return $this->xRequestHandler->getCallbackManager();
511
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
512
513
    /**
514
     * Get the template engine
515
     *
516
     * @return TemplateEngine
517
     */
518
    public function template(): TemplateEngine
519
    {
520
        return $this->di()->getTemplateEngine();
521
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
522
523
    /**
524
     * Get the App instance
525
     *
526
     * @return App
527
     */
528
    public function app(): App
529
    {
530
        return $this->di()->getApp();
531
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
532
533
    /**
534
     * Get the view renderer
535
     *
536
     * @return ViewRenderer
537
     */
538
    public function view(): ViewRenderer
539
    {
540
        return $this->di()->getViewRenderer();
541
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
542
543
    /**
544
     * Get the session manager
545
     *
546
     * @return SessionInterface
547
     */
548
    public function session(): SessionInterface
549
    {
550
        return $this->di()->getSessionManager();
551
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
552
}
553