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 ( 055333...553c84 )
by TJ
01:15
created

HoneybadgerContext::setUserContext()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
3
namespace Honeybadger\HoneybadgerLaravel\Middleware;
4
5
use Closure;
6
use Honeybadger\Contracts\Reporter;
7
use Illuminate\Support\Facades\Route;
8
9
class HoneybadgerContext
10
{
11
    /**
12
     * @var \Honeybadger\Honeybadger;
13
     */
14
    protected $honeybadger;
15
16
    /**
17
     * @param  \Honeybadger\Contracts\Reporter  $honeybadger
18
     */
19
    public function __construct(Reporter $honeybadger)
20
    {
21
        $this->honeybadger = $honeybadger;
22
    }
23
24
    /**
25
     * Handle an incoming request.
26
     *
27
     * @param  \Illuminate\Http\Request  $request
28
     * @param  \Closure  $next
29
     * @return mixed
30
     */
31
    public function handle($request, Closure $next)
32
    {
33
        if (app()->bound('honeybadger')) {
34
            $this->setUserContext($request);
35
            $this->setRouteActionContext();
36
        }
37
38
        return $next($request);
39
    }
40
41
    private function setRouteActionContext()
42
    {
43
        if (Route::getCurrentRoute()) {
0 ignored issues
show
Bug introduced by
The method getCurrentRoute() does not exist on Illuminate\Support\Facades\Route. Did you maybe mean current()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
44
            $routeAction = explode('@', Route::getCurrentRoute()->getActionName());
0 ignored issues
show
Bug introduced by
The method getCurrentRoute() does not exist on Illuminate\Support\Facades\Route. Did you maybe mean current()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
45
46
            $this->honeybadger->setComponent($routeAction[0] ?? null);
0 ignored issues
show
Bug introduced by
The method setComponent() does not seem to exist on object<Honeybadger\Contracts\Reporter>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
47
            $this->honeybadger->setAction($routeAction[1] ?? null);
0 ignored issues
show
Bug introduced by
The method setAction() does not seem to exist on object<Honeybadger\Contracts\Reporter>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
48
        }
49
    }
50
51
    private function setUserContext($request)
52
    {
53
        if ($request->user()) {
54
            $this->honeybadger->context(
55
                'user_id',
56
                $request->user()->getAuthIdentifier()
57
            );
58
        }
59
    }
60
}
61