Passed
Push — v5.x ( 87a13b...e527ef )
by Thierry
02:13
created

JQueryPlugin::command()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
nc 1
nop 1
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace Jaxon\Plugin\Response\JQuery;
4
5
use Jaxon\Plugin\ResponsePlugin;
6
use Jaxon\Request\Js\Selector;
7
8
class JQueryPlugin extends ResponsePlugin
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class JQueryPlugin
Loading history...
9
{
10
    /**
11
     * @const The plugin name
12
     */
13
    const NAME = 'jquery';
14
15
    /**
16
     * @inheritDoc
17
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
18
    public function getName(): string
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
19
    {
20
        return self::NAME;
21
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
22
23
    /**
24
     * @inheritDoc
25
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
26
    public function getHash(): string
27
    {
28
        // Use the version number as hash
29
        return '4.0.0';
30
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
31
32
    /**
33
     * Create a JQueryPlugin Selector, and link it to the current response.
34
     *
35
     * Since this element is linked to a response, its code will be automatically sent to the client.
36
     * The returned object can be used to call jQuery functions on the selected elements.
37
     *
38
     * @param string $sPath    The jQuery selector path
39
     * @param mixed $xContext    A context associated to the selector
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...
40
     *
41
     * @return Selector
42
     */
43
    public function selector(string $sPath = '', $xContext = null): Selector
44
    {
45
        $xSelector = new Selector($sPath, $xContext);
46
        $this->addCommand('jquery.call', ['selector' => $xSelector]);
47
        return $xSelector;
48
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
49
}
50