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
Pull Request — master (#57)
by TJ
03:11
created

Honeybadger::checkin()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Honeybadger;
4
5
use Throwable;
6
use GuzzleHttp\Client;
7
use Honeybadger\Concerns\Newable;
8
use Honeybadger\Contracts\Reporter;
9
use Honeybadger\Support\Repository;
10
use Honeybadger\Handlers\ErrorHandler;
11
use Honeybadger\Handlers\ExceptionHandler;
12
use Honeybadger\Exceptions\ServiceException;
13
use Symfony\Component\HttpFoundation\Request as FoundationRequest;
14
15
class Honeybadger implements Reporter
16
{
17
    use Newable;
18
19
    /**
20
     * SDK Version.
21
     */
22
    const VERSION = '1.0.0';
23
24
    /**
25
     * Honeybadger API URL.
26
     */
27
    const API_URL = 'https://api.honeybadger.io/v1/';
28
29
    /**
30
     * @var \Honeybadger\HoneybadgerClient;
31
     */
32
    protected $client;
33
34
    /**
35
     * @var \Honeybadger\Config
36
     */
37
    protected $config;
38
39
    /**
40
     * @var \Honeybadger\Support\Repository
41
     */
42
    protected $context;
43
44
    /**
45
     * @param  array  $config
46
     * @param  \GuzzleHttp\Client  $client
47
     */
48
    public function __construct(array $config = [], Client $client = null)
49
    {
50
        $this->config = new Config($config);
51
52
        $this->client = new HoneybadgerClient($this->config, $client);
53
        $this->context = new Repository;
54
55
        $this->setHandlers();
56
    }
57
58
    /**
59
     * {@inheritdoc}
60
     */
61
    public function notify(Throwable $throwable, FoundationRequest $request = null) : void
62
    {
63
        if ($this->excludedException($throwable)) {
64
            return;
65
        }
66
67
        $notification = (new ExceptionNotification($this->config, $this->context))
68
            ->make($throwable, $request);
69
70
        $this->client->notification($notification);
71
    }
72
73
    /**
74
     * {@inheritdoc}
75
     */
76
    public function customNotification(array $payload) : void
77
    {
78
        $notification = (new CustomNotification($this->config, $this->context))
79
            ->make($payload);
80
81
        $this->client->notification($notification);
82
    }
83
84
    /**
85
     * {@inheritdoc}
86
     */
87
    public function checkin(string $key) : void
88
    {
89
        $this->client->checkin($key);
90
    }
91
92
    /**
93
     * @param  int|string  $key
94
     * @param  int|string  $value
95
     * @return void
96
     */
97
    public function context($key, $value) : void
98
    {
99
        $this->context->set($key, $value);
100
    }
101
102
    /**
103
     * @return void
104
     */
105
    private function setHandlers() : void
106
    {
107
        if ($this->config['handlers']['exception']) {
108
            (new ExceptionHandler($this))->register();
109
        }
110
111
        if ($this->config['handlers']['error']) {
112
            (new ErrorHandler($this))->register();
113
        }
114
    }
115
116
    /**
117
     * @param  \Throwable  $throwable
118
     * @return bool
119
     */
120
    private function excludedException(Throwable $throwable) : bool
121
    {
122
        return $throwable instanceof ServiceException
123
            || in_array(
124
                get_class($throwable),
125
                $this->config['excluded_exceptions']
126
            );
127
    }
128
}
129