ListenNode   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 6
c 1
b 0
f 0
dl 0
loc 27
ccs 6
cts 6
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A __toString() 0 3 1
1
<?php
2
3
namespace MallardDuck\DynamicEcho\ScriptGenerator\Nodes;
4
5
class ListenNode extends ScriptNode
6
{
7
    /**
8
     * @var string The name of the Echo event to listen to.
9
     */
10
    private string $eventName;
11
12
    /**
13
     * @var string The Javascript callback used as the event listener.
14
     */
15
    private string $listenerCallback;
16
17
    /**
18
     * ListenNode constructor.
19
     *
20
     * @param string $eventName The name of the echo event.
21
     * @param string $callback  A javascript event callback used as the listener.
22
     */
23 2
    public function __construct(string $eventName, string $callback)
24
    {
25 2
        $this->eventName = $eventName;
26 2
        $this->listenerCallback = $callback;
27 2
    }
28
29 1
    public function __toString()
30
    {
31 1
        return sprintf(".listen('%s', %s)", $this->eventName, $this->listenerCallback);
32
    }
33
}
34