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

Request::session()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 2
nc 4
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Honeybadger;
4
5
use Honeybadger\Concerns\FiltersData;
6
use Symfony\Component\HttpFoundation\Request as FoundationRequest;
7
8
class Request
9
{
10
    use FiltersData;
11
12
    /**
13
     * @var \Symfony\Component\HttpFoundation\Request
14
     */
15
    protected $request;
16
17
    /**
18
     * @param  \Symfony\Component\HttpFoundation\Request  $request
19
     */
20
    public function __construct(FoundationRequest $request = null)
21
    {
22
        $this->request = $request ?? FoundationRequest::createFromGlobals();
23
24
        $this->keysToFilter = [
25
            'password',
26
            'password_confirmation',
27
        ];
28
    }
29
30
    /**
31
     * @return string
32
     */
33
    public function url() : string
34
    {
35
        return $this->httpRequest()
36
            ? $this->request->getUri()
37
            : '';
38
    }
39
40
    /**
41
     * @return array
42
     */
43
    public function params() : array
44
    {
45
        if (! $this->httpRequest()) {
46
            return [];
47
        }
48
49
        return [
50
            'method' => $this->request->getMethod(),
51
            'query' => $this->filter($this->request->query->all()),
52
            'data' => $this->filter($this->data()),
53
        ];
54
    }
55
56
    /**
57
     * @return array
58
     */
59
    public function session() : array
60
    {
61
        return $this->request->hasSession() && $this->request->getSession()
62
            ? $this->filter($this->request->getSession()->all())
63
            : [];
64
    }
65
66
    /**
67
     * @return bool
68
     */
69
    private function httpRequest() : bool
70
    {
71
        return isset($_SERVER['REQUEST_METHOD']);
72
    }
73
74
    /**
75
     * @return array
76
     */
77
    private function data() : array
78
    {
79
        if ($this->request->getContentType() === 'json') {
80
            return json_decode($this->request->getContent(), true) ?: [];
81
        }
82
83
        if ($this->request->getContentType() === 'form') {
84
            return $this->request->request->all();
85
        }
86
87
        return [];
88
    }
89
}
90