GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( c9301d...39b3bd )
by Pascal
20s queued 11s
created

Event::__isset()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace ProtoneMedia\LaravelPaddle\Events;
4
5
use Illuminate\Support\Str;
6
7
abstract class Event
8
{
9
    /**
10
     * @var array
11
     */
12
    protected $webhookData;
13
14
    public function __construct(array $webhookData)
15
    {
16
        $this->webhookData = $webhookData;
17
    }
18
19
    /**
20
     * Getter for all data.
21
     *
22
     * @return array
23
     */
24
    public function all(): array
25
    {
26
        return $this->webhookData;
27
    }
28
29
    /**
30
     * Getter for the webhook data.
31
     *
32
     * @param  string $key
33
     * @return mixed
34
     */
35
    public function __get(string $key)
36
    {
37
        $value = $this->webhookData[$key];
38
39
        if ($key === 'passthrough') {
40
            $result = json_decode($value, true);
41
42
            if (json_last_error() === JSON_ERROR_NONE) {
43
                return $result;
44
            }
45
        }
46
47
        return $value;
48
    }
49
50
    /**
51
     * Determine if an attribute exists on the webhook data.
52
     *
53
     * @param  string $key
54
     * @return bool
55
     */
56
    public function __isset($key)
57
    {
58
        return isset($this->webhookData[$key]);
59
    }
60
61
    /**
62
     * Generates the event class name with the 'alert_name' attribute from
63
     * the data and fires the event with the data.
64
     *
65
     * @param  array  $data
66
     * @return void
67
     */
68
    public static function fire(array $data)
69
    {
70
        $event = Str::studly($data['alert_name']);
71
72
        $eventClass = __NAMESPACE__ . '\\' . $event;
73
74
        event(new $eventClass($data));
75
    }
76
}
77