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.

AbstractPayloadResponse::getPossibleErrors()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 28

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 25
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 28
ccs 25
cts 25
cp 1
rs 9.472
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace CL\Slack\Payload;
4
5
/**
6
 * @author Cas Leentfaar <[email protected]>
7
 */
8
abstract class AbstractPayloadResponse implements PayloadResponseInterface
9
{
10
    /**
11
     * @var bool
12
     */
13
    private $ok;
14
15
    /**
16
     * @var string
17
     */
18
    private $error;
19
20
    /**
21
     * @inheritdoc
22
     */
23 57
    public function isOk()
24
    {
25 57
        return (bool) $this->ok;
26
    }
27
28
    /**
29
     * @inheritdoc
30
     */
31 58
    public function getError()
32
    {
33 58
        return $this->error;
34
    }
35
36
    /**
37
     * @inheritdoc
38
     */
39 57
    public function getErrorExplanation()
40
    {
41 57
        if (null === $error = $this->getError()) {
42 1
            return null;
43
        }
44
45 56
        $ownErrors = $this->getPossibleErrors();
46 56
        if (array_key_exists($error, $ownErrors)) {
47 56
            return $ownErrors[$error];
48
        }
49
50
        return sprintf('Unknown error: "%s"', $error);
51
    }
52
53
    /**
54
     * @return array
55
     */
56 56
    protected function getPossibleErrors()
57
    {
58
        return [
59 56
            'account_inactive' => 'Authentication token is for a deleted user or team',
60 56
            'already_archived' => 'Channel has already been archived',
61 56
            'already_in_channel' => 'Invited user is already in the channel',
62 56
            'invalid_auth' => 'Invalid authentication token',
63 56
            'invalid_token' => 'Invalid token supplied',
64 56
            'cant_archive_general' => 'You cannot archive the general channel',
65 56
            'cant_invite' => 'User cannot be invited to this channel',
66 56
            'cant_invite_self' => 'Authenticated user cannot invite themselves to a channel',
67 56
            'cant_kick_from_general' => 'User cannot be removed from #general',
68 56
            'cant_kick_from_last_channel' => 'User cannot be removed from the last channel they\'re in',
69 56
            'cant_kick_self' => 'Authenticated user can\'t kick themselves from a channel',
70 56
            'channel_not_found' => 'Channel could not be found',
71 56
            'is_archived' => 'Channel has been archived',
72 56
            'last_ra_channel' => 'You cannot archive the last channel for a restricted account',
73 56
            'name_taken' => 'A channel cannot be created with the given name',
74 56
            'no_channel' => 'A value passed for name was empty',
75 56
            'not_authed' => 'No authentication token provided',
76 56
            'not_in_channel' => 'User was not in the channel',
77 56
            'rate_limited' => 'Application has posted too many messages, read the Rate Limit documentation (https://api.slack.com/docs/rate-limits) for more information',
78 56
            'restricted_action' => 'A team preference prevents authenticated user from archiving',
79 56
            'user_is_bot' => 'This method cannot be called by a bot user',
80 56
            'user_is_ultra_restricted' => 'This method cannot be called by a single channel guest',
81 56
            'user_not_found' => 'User could not be found',
82 56
        ];
83
    }
84
}
85