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.

Request   A
last analyzed

Complexity

Total Complexity 13

Size/Duplication

Total Lines 81
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 24
c 1
b 0
f 0
dl 0
loc 81
rs 10
wmc 13

6 Methods

Rating   Name   Duplication   Size   Complexity  
A params() 0 10 2
A url() 0 5 2
A data() 0 11 4
A session() 0 5 3
A httpRequest() 0 3 1
A __construct() 0 7 1
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
     * @param  array  $options
20
     */
21
    public function __construct(FoundationRequest $request = null)
22
    {
23
        $this->request = $request ?? FoundationRequest::createFromGlobals();
24
25
        $this->keysToFilter = [
26
            'password',
27
            'password_confirmation',
28
        ];
29
    }
30
31
    /**
32
     * @return string
33
     */
34
    public function url(): string
35
    {
36
        return $this->httpRequest()
37
            ? $this->request->getUri()
38
            : '';
39
    }
40
41
    /**
42
     * @return array
43
     */
44
    public function params(): array
45
    {
46
        if (! $this->httpRequest()) {
47
            return [];
48
        }
49
50
        return [
51
            'method' => $this->request->getMethod(),
52
            'query' => $this->filter($this->request->query->all()),
53
            'data' => $this->filter($this->data()),
54
        ];
55
    }
56
57
    /**
58
     * @return array
59
     */
60
    public function session(): array
61
    {
62
        return $this->request->hasSession() && $this->request->getSession()
63
            ? $this->filter($this->request->getSession()->all())
64
            : [];
65
    }
66
67
    /**
68
     * @return bool
69
     */
70
    private function httpRequest(): bool
71
    {
72
        return isset($_SERVER['REQUEST_METHOD']);
73
    }
74
75
    /**
76
     * @return array
77
     */
78
    private function data(): array
79
    {
80
        if ($this->request->getContentType() === 'json') {
81
            return json_decode($this->request->getContent(), true) ?: [];
82
        }
83
84
        if ($this->request->getContentType() === 'form') {
85
            return $this->request->request->all();
86
        }
87
88
        return [];
89
    }
90
}
91