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.
Passed
Push — master ( 7cb54d...804d9a )
by TJ
03:44
created

RawNotification::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Honeybadger;
4
5
use InvalidArgumentException;
6
use Honeybadger\Support\Repository;
7
8
class RawNotification
9
{
10
    /**
11
     * @var \Honeybadger\Config
12
     */
13
    protected $config;
14
15
    /**
16
     * @var \Honeybadger\Support\Repository
17
     */
18
    protected $context;
19
20
    /**
21
     * @param  \Honeybadger\Config  $config
22
     * @param  \Honeybadger\Support\Repository  $context
23
     */
24
    public function __construct(Config $config, Repository $context)
25
    {
26
        $this->config = $config;
27
        $this->context = $context;
28
    }
29
30
    /**
31
     * @param  array  $payload
32
     * @return array
33
     *
34
     * @throws \InvalidArgumentException
35
     */
36
    public function make(array $payload) : array
37
    {
38
        $payload = array_merge(
39
            [],
40
            ['notifier' => $this->config['notifier']],
41
            ['error' => []],
42
            ['request' => ['context' => (object) $this->context->all()],
43
            ],
44
            ['server' => (object) []],
45
            $payload
46
        );
47
48
        $this->validatePayload($payload);
49
50
        return $payload;
51
    }
52
53
    /**
54
     * @param  array  $payload
55
     * @return void
56
     *
57
     * @throws \InvalidArgumentException
58
     */
59
    private function validatePayload(array $payload) : void
60
    {
61
        if (empty($payload['error']['class'])) {
62
            throw new InvalidArgumentException('The notification error.class field is required');
63
        }
64
65
        if (empty($payload['notifier']['name'])) {
66
            throw new InvalidArgumentException('The notification notifier.name field is required');
67
        }
68
    }
69
}
70