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.

AppServiceProvider::versionData()   A
last analyzed

Complexity

Conditions 4
Paths 1

Size

Total Lines 21
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 21
rs 9.0534
c 0
b 0
f 0
cc 4
eloc 12
nc 1
nop 0
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\Providers;
26
27
use View;
28
use Cache;
29
use Pterodactyl\Models;
30
use Pterodactyl\Observers;
31
use Illuminate\Support\ServiceProvider;
32
33
class AppServiceProvider extends ServiceProvider
34
{
35
    /**
36
     * Bootstrap any application services.
37
     *
38
     * @return void
39
     */
40
    public function boot()
41
    {
42
        Models\User::observe(Observers\UserObserver::class);
43
        Models\Server::observe(Observers\ServerObserver::class);
44
        Models\Subuser::observe(Observers\SubuserObserver::class);
45
46
        View::share('appVersion', $this->versionData()['version'] ?? 'undefined');
47
        View::share('appIsGit', $this->versionData()['is_git'] ?? false);
48
    }
49
50
    /**
51
     * Register any application services.
52
     *
53
     * @return void
54
     */
55
    public function register()
56
    {
57
        if ($this->app->environment() !== 'production') {
58
            $this->app->register(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class);
59
        }
60
61
        if (config('pterodactyl.auth.notifications')) {
62
            $this->app->register(\DaneEveritt\LoginNotifications\NotificationServiceProvider::class);
63
        }
64
    }
65
66
    /**
67
     * Return version information for the footer.
68
     *
69
     * @return array
70
     */
71
    protected function versionData()
72
    {
73
        return Cache::remember('git-version', 5, function () {
74
            if (file_exists(base_path('.git/HEAD'))) {
75
                $head = explode(' ', file_get_contents(base_path('.git/HEAD')));
76
                $path = base_path('.git/' . trim($head[1]));
77
            }
78
79
            if (isset($path) && file_exists($path)) {
80
                return [
81
                    'version' => substr(file_get_contents($path), 0, 8),
82
                    'is_git' => true,
83
                ];
84
            }
85
86
            return [
87
                'version' => config('app.version'),
88
                'is_git' => false,
89
            ];
90
        });
91
    }
92
}
93