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.

ServerObserver   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 113
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 10

Importance

Changes 0
Metric Value
wmc 8
c 0
b 0
f 0
lcom 0
cbo 10
dl 0
loc 113
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A creating() 0 4 1
A created() 0 14 1
A deleting() 0 4 1
A deleted() 0 4 1
A saving() 0 4 1
A saved() 0 4 1
A updating() 0 4 1
A updated() 0 15 1
1
<?php
2
/**
3
 * Pterodactyl - Panel
4
 * Copyright (c) 2015 - 2017 Dane Everitt <[email protected]>.
5
 *
6
 * Permission is hereby granted, free of charge, to any person obtaining a copy
7
 * of this software and associated documentation files (the "Software"), to deal
8
 * in the Software without restriction, including without limitation the rights
9
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
 * copies of the Software, and to permit persons to whom the Software is
11
 * furnished to do so, subject to the following conditions:
12
 *
13
 * The above copyright notice and this permission notice shall be included in all
14
 * copies or substantial portions of the Software.
15
 *
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
 * SOFTWARE.
23
 */
24
25
namespace Pterodactyl\Observers;
26
27
use Cache;
28
use Pterodactyl\Events;
29
use Pterodactyl\Models\Server;
30
use Pterodactyl\Notifications\ServerCreated;
31
use Illuminate\Foundation\Bus\DispatchesJobs;
32
33
class ServerObserver
34
{
35
    use DispatchesJobs;
36
37
    /**
38
     * Listen to the Server creating event.
39
     *
40
     * @param  \Pterodactyl\Models\Server  $server
41
     * @return void
42
     */
43
    public function creating(Server $server)
44
    {
45
        event(new Events\Server\Creating($server));
46
    }
47
48
    /**
49
     * Listen to the Server created event.
50
     *
51
     * @param  \Pterodactyl\Models\Server  $server
52
     * @return void
53
     */
54
    public function created(Server $server)
55
    {
56
        event(new Events\Server\Created($server));
57
58
        // Queue Notification Email
59
        $server->user->notify((new ServerCreated([
60
            'name' => $server->name,
61
            'memory' => $server->memory,
62
            'node' => $server->node->name,
63
            'service' => $server->service->name,
64
            'option' => $server->option->name,
65
            'uuidShort' => $server->uuidShort,
66
        ])));
67
    }
68
69
    /**
70
     * Listen to the Server deleting event.
71
     *
72
     * @param  \Pterodactyl\Models\Server  $server
73
     * @return void
74
     */
75
    public function deleting(Server $server)
76
    {
77
        event(new Events\Server\Deleting($server));
78
    }
79
80
    /**
81
     * Listen to the Server deleted event.
82
     *
83
     * @param  \Pterodactyl\Models\Server  $server
84
     * @return void
85
     */
86
    public function deleted(Server $server)
87
    {
88
        event(new Events\Server\Deleted($server));
89
    }
90
91
    /**
92
     * Listen to the Server saving event.
93
     *
94
     * @param  \Pterodactyl\Models\Server  $server
95
     * @return void
96
     */
97
    public function saving(Server $server)
98
    {
99
        event(new Events\Server\Saving($server));
100
    }
101
102
    /**
103
     * Listen to the Server saved event.
104
     *
105
     * @param  \Pterodactyl\Models\Server  $server
106
     * @return void
107
     */
108
    public function saved(Server $server)
109
    {
110
        event(new Events\Server\Saved($server));
111
    }
112
113
    /**
114
     * Listen to the Server updating event.
115
     *
116
     * @param  \Pterodactyl\Models\Server  $server
117
     * @return void
118
     */
119
    public function updating(Server $server)
120
    {
121
        event(new Events\Server\Updating($server));
122
    }
123
124
    /**
125
     * Listen to the Server saved event.
126
     *
127
     * @param  \Pterodactyl\Models\Server  $server
128
     * @return void
129
     */
130
    public function updated(Server $server)
131
    {
132
        /*
133
         * The cached byUuid model calls are tagged with Model:Server:byUuid:<uuid>
134
         * so that they can be accessed regardless of if there is an Auth::user()
135
         * defined or not.
136
         *
137
         * We can also delete all cached byUuid items using the Model:Server tag.
138
         */
139
        Cache::tags('Model:Server:byUuid:' . $server->uuid)->flush();
140
        Cache::tags('Model:Server:byUuid:' . $server->uuidShort)->flush();
141
        Cache::tags('Downloads:Server:' . $server->uuid)->flush();
142
143
        event(new Events\Server\Updated($server));
144
    }
145
}
146