AbstractEvent::setPayload()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace SfCod\SocketIoBundle\Events;
4
5
/**
6
 * Class AbstractEvent.
7
 *
8
 * @author Virchenko Maksim <[email protected]>
9
 *
10
 * @package SfCod\SocketIoBundle\Events
11
 */
12
abstract class AbstractEvent implements EventInterface
13
{
14
    /**
15
     * Please, define '@property' and use it using magic __get() method instead of using $this->payload.
16
     *
17
     * @var array
18
     */
19
    protected $payload;
20
21
    /**
22
     * @param $data
23
     */
24
    public function setPayload($data): EventInterface
25
    {
26
        $this->payload = $data;
27
28
        return $this;
29
    }
30
31
    /**
32
     * Magic get.
33
     *
34
     * @param $name
35
     *
36
     * @return mixed
37
     */
38
    public function __get($name)
39
    {
40
        if (isset($this->payload[$name])) {
41
            return $this->payload[$name];
42
        }
43
44
        return null;
45
    }
46
}
47