ScriptNodeBuilder::getRootEchoNode()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 1
c 1
b 0
f 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace MallardDuck\DynamicEcho\ScriptGenerator;
4
5
use MallardDuck\DynamicEcho\ScriptGenerator\Nodes\ChannelContextNode;
6
use MallardDuck\DynamicEcho\ScriptGenerator\Nodes\ListenNode;
7
use MallardDuck\DynamicEcho\ScriptGenerator\Nodes\PrivateChannelNode;
8
use MallardDuck\DynamicEcho\ScriptGenerator\Nodes\RootEchoNode;
9
10
class ScriptNodeBuilder
11
{
12
    /**
13
     * @return RootEchoNode
14
     */
15 8
    public static function getRootEchoNode(): RootEchoNode
16
    {
17 8
        return new RootEchoNode();
18
    }
19
20
    /**
21
     * Builds a private Echo channel.
22
     *
23
     * @param string $channelIdentifier The name of the echo event channel.
24
     *
25
     * @return PrivateChannelNode
26
     */
27 3
    public static function getPrivateChannelNode(string $channelIdentifier): PrivateChannelNode
28
    {
29 3
        return new PrivateChannelNode($channelIdentifier);
30
    }
31
32
    /**
33
     * Builds a private Echo channel.
34
     *
35
     * @param string $eventName The name of the echo event.
36
     *
37
     * @param string $callback  A javascript event callback used as the listener.
38
     *
39
     * @return ListenNode
40
     */
41 2
    public static function getListenNode(string $eventName, string $callback): ListenNode
42
    {
43 2
        return new ListenNode($eventName, $callback);
44
    }
45
46 3
    public static function getChannelContextNode(string $getChannelJsVarKey, array $channelContext)
47
    {
48 3
        return new ChannelContextNode($getChannelJsVarKey, $channelContext);
49
    }
50
}
51