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.

HoneybadgerTestCommand::handle()   A
last analyzed

Complexity

Conditions 4
Paths 15

Size

Total Lines 20
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 13
c 2
b 0
f 0
dl 0
loc 20
rs 9.8333
cc 4
nc 15
nop 0
1
<?php
2
3
namespace Honeybadger\HoneybadgerLaravel\Commands;
4
5
use Exception;
6
use Honeybadger\Contracts\Reporter;
7
use Honeybadger\HoneybadgerLaravel\Exceptions\TestException;
8
use Illuminate\Console\Command;
9
10
class HoneybadgerTestCommand extends Command
11
{
12
    /**
13
     * The name and signature of the console command.
14
     *
15
     * @var string
16
     */
17
    protected $signature = 'honeybadger:test';
18
19
    /**
20
     * The console command description.
21
     *
22
     * @var string
23
     */
24
    protected $description = 'Tests notifications to Honeybadger';
25
26
    public function handle()
27
    {
28
        /** @var Reporter $honeybadger */
29
        $honeybadger = app('honeybadger.loud');
30
31
        try {
32
            if (! config('honeybadger.report_data')) {
33
                $this->info("You have `report_data` set to false in your config. Errors won't be reported in this environment.");
34
                $this->info("We've switched it to true for this test, but you should check that it's enabled for your production environments.");
35
            }
36
            $result = $honeybadger->notify(new TestException);
37
            $id = $result['id'] ?? null;
38
            if (is_null($id)) {
39
                throw new Exception('There was an error sending the exception to Honeybadger');
40
            }
41
42
            $noticeUrl = "https://app.honeybadger.io/notice/$id";
43
            $this->info("Successfully sent a test exception to Honeybadger: $noticeUrl");
44
        } catch (Exception $e) {
45
            $this->error($e->getMessage());
46
        }
47
    }
48
}
49