Passed
Push — main ( 82104f...ee6fb2 )
by Thierry
05:16
created

JsCode   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 56
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A files() 0 3 1
A before() 0 3 1
A __construct() 0 3 1
A after() 0 3 1
A code() 0 3 1
1
<?php
2
3
/**
4
 * JsCode.php
5
 *
6
 * The javascript codes generated by a Jaxon plugin.
7
 *
8
 * @package jaxon-core
9
 * @author Thierry Feuzeu <[email protected]>
10
 * @copyright 2025 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-core
13
 */
14
15
namespace Jaxon\Plugin;
16
17
class JsCode
18
{
19
    /**
20
     * @param string $sCode
21
     * @param array $aFiles
22
     */
23
    public function __construct(protected string $sCode = '', protected array $aFiles = [],
24
        protected string $sCodeBefore = '', protected string $sCodeAfter = '')
25
    {}
26
27
    /**
28
     * Get the javascript code to include into the page
29
     *
30
     * The code must NOT be enclosed in HTML tags.
31
     *
32
     * @return string
33
     */
34
    public function code(): string
35
    {
36
        return $this->sCode;
37
    }
38
39
    /**
40
     * Get the javascript files to include into the page
41
     *
42
     * Each entry can be a string or an array with "uri" and "options".
43
     *
44
     * @return array
45
     */
46
    public function files(): array
47
    {
48
        return $this->aFiles;
49
    }
50
51
    /**
52
     * Get the javascript code to be inserted inline before the main code
53
     *
54
     * The code must NOT be enclosed in HTML tags.
55
     *
56
     * @return string
57
     */
58
    public function before(): string
59
    {
60
        return $this->sCodeBefore;
61
    }
62
63
    /**
64
     * Get the javascript code to be inserted inline after the main code
65
     *
66
     * The code must NOT be enclosed in HTML tags.
67
     *
68
     * @return string
69
     */
70
    public function after(): string
71
    {
72
        return $this->sCodeAfter;
73
    }
74
}
75