JxnCall::_expr()   A
last analyzed

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 Jaxon\Script;
4
5
/**
6
 * JxnCall.php
7
 *
8
 * Call to a Jaxon registered function or class.
9
 *
10
 * @package jaxon-core
11
 * @author Thierry Feuzeu
12
 * @copyright 2024 Thierry Feuzeu <[email protected]>
13
 * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
14
 * @link https://github.com/jaxon-php/jaxon-core
15
 */
16
17
 use Jaxon\Plugin\Response\Dialog\DialogCommand;
18
19
class JxnCall extends AbstractCall
20
{
21
    /**
22
     * The Jaxon function prefix
23
     *
24
     * @var string
25
     */
26
    protected $sPrefix;
27
28
    /**
29
     * The constructor.
30
     *
31
     * @param DialogCommand $xDialog
32
     * @param string $sPrefix
33
     */
34
    public function __construct(DialogCommand $xDialog, string $sPrefix)
35
    {
36
        $this->xDialog = $xDialog;
37
        $this->sPrefix = $sPrefix;
38
    }
39
40
    /**
41
     * Create a js expression
42
     *
43
     * @return JsExpr
44
     */
45
    protected function _expr(): JsExpr
46
    {
47
        return new JsExpr($this->xDialog);
48
    }
49
50
    /**
51
     * Add a call to a js function on the current object
52
     *
53
     * @param string  $sMethod
54
     * @param array  $aArguments
55
     *
56
     * @return JsExpr
57
     */
58
    public function __call(string $sMethod, array $aArguments): JsExpr
59
    {
60
        // Append the prefix to the method name
61
        return parent::__call($this->sPrefix . $sMethod, $aArguments);
62
    }
63
64
    /**
65
     * Get the js class name
66
     *
67
     * @return string
68
     */
69
    public function _class(): string
70
    {
71
        return '';
72
    }
73
}
74