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.

Bots::info()   A
last analyzed

Complexity

Conditions 4
Paths 6

Size

Total Lines 30

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 30
rs 9.44
c 0
b 0
f 0
cc 4
nc 6
nop 1
1
<?php
2
3
/*
4
 * This file is part of Slackify.
5
 *
6
 * (c) Strime <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Strime\Slackify\Api;
13
14
use Strime\Slackify\Exception\RuntimeException;
15
use Strime\Slackify\Exception\InvalidArgumentException;
16
use GuzzleHttp\Exception\RequestException;
17
18
class Bots extends AbstractApi
19
{
20
    /**
21
     * {@inheritdoc}
22
     *
23
     * @param  string $bot
24
     * @return Bots
25
     */
26
    public function info($bot = NULL) {
27
28
        // Check if the type of the variables is valid.
29
        if (!is_string($bot)) {
30
            throw new InvalidArgumentException("The type of the bot variable is not valid.");
31
        }
32
33
        // Set the arguments of the request
34
        $arguments = array(
35
            "bot" => $bot
36
        );
37
38
        $this->setUrl("bots.info", $arguments);
39
40
        // Send the request
41
        try {
42
            $client = new \GuzzleHttp\Client();
43
            $json_response = $client->request('GET', $this->getUrl(), []);
44
            $response = json_decode( $json_response->getBody() );
45
        }
46
        catch (RequestException $e) {
47
            throw new RuntimeException('The request to the API failed: '.$e->getMessage(), $e->getCode(), $e);
48
        }
49
50
        if($response->{'ok'} === FALSE) {
51
            throw new RuntimeException('The request to the API failed: '.$response->{'error'}.".");
52
        }
53
54
        return $json_response->getBody();
55
    }
56
}
57