Completed
Push — master ( 6b754f...e913ef )
by Sebastien
03:10 queued 52s
created

EventBase::getSender()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Smalot\Github\Webhook\Event;
4
5
/**
6
 * Class EventBase
7
 * @package Smalot\Github\Webhook\Event
8
 */
9
abstract class EventBase
10
{
11
    /**
12
     * @var string
13
     */
14
    protected $eventName;
15
16
    /**
17
     * @var array
18
     */
19
    protected $payload;
20
21
    /**
22
     * @var string
23
     */
24
    protected $delivery;
25
26
    /**
27
     * EventBase constructor.
28
     * @param string $eventName
29
     * @param string $payload
30
     * @param string $delivery
31
     */
32
    public function __construct($eventName, $payload, $delivery = null)
33
    {
34
        $this->eventName = $eventName;
35
        $this->payload = json_decode($payload, true);
0 ignored issues
show
Documentation Bug introduced by
It seems like json_decode($payload, true) of type * is incompatible with the declared type array of property $payload.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
36
        $this->delivery = $delivery;
37
    }
38
39
    /**
40
     * @return string
41
     */
42
    abstract public function getEventName();
43
44
    /**
45
     * @return array
46
     */
47
    public function getPayload()
48
    {
49
        return $this->payload;
50
    }
51
52
    /**
53
     * @return string
54
     */
55
    public function getDelivery()
56
    {
57
        return $this->delivery;
58
    }
59
60
    /**
61
     * @return array
62
     */
63
    public function getRepository()
64
    {
65
        return $this->payload['repository'];
66
    }
67
68
    /**
69
     * @return array
70
     */
71
    public function getSender()
72
    {
73
        return $this->payload['sender'];
74
    }
75
}
76