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

EventBase   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 3
Bugs 0 Features 2
Metric Value
wmc 5
c 3
b 0
f 2
lcom 1
cbo 0
dl 0
loc 67
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
getEventName() 0 1 ?
A getPayload() 0 4 1
A getDelivery() 0 4 1
A getRepository() 0 4 1
A getSender() 0 4 1
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