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.

AuthTestCommand   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 6
Bugs 1 Features 1
Metric Value
wmc 5
c 6
b 1
f 1
lcom 2
cbo 4
dl 0
loc 55
ccs 24
cts 24
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 16 1
A createPayload() 0 4 1
A handleResponse() 0 19 3
1
<?php
2
3
/*
4
 * This file is part of the slack-cli package.
5
 *
6
 * (c) Cas Leentfaar <[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 CL\SlackCli\Command;
13
14
use CL\Slack\Payload\AuthTestPayload;
15
use CL\Slack\Payload\AuthTestPayloadResponse;
16
use Symfony\Component\Console\Output\OutputInterface;
17
18
/**
19
 * @author Cas Leentfaar <[email protected]>
20
 */
21
class AuthTestCommand extends AbstractApiCommand
22
{
23
    /**
24
     * {@inheritDoc}
25
     */
26 1
    protected function configure()
27
    {
28 1
        parent::configure();
29
30 1
        $this->setName('auth:test');
31 1
        $this->setDescription('Test authentication with the Slack API and, optionally, tells you who you are (use -v).');
32 1
        $this->setHelp(<<<EOT
33
The <info>auth:test</info> command lets you test authenticating with the Slack API.
34
35
Use the verbose option `-v` to also return information about the token's user.
36
37
For more information about the related API method, check out the official documentation:
38
<comment>https://api.slack.com/methods/auth.test</comment>
39
EOT
40 1
        );
41 1
    }
42
43
    /**
44
     * @return AuthTestPayload
45
     */
46 1
    protected function createPayload()
47
    {
48 1
        return new AuthTestPayload();
49
    }
50
51
    /**
52
     * {@inheritdoc}
53
     *
54
     * @param AuthTestPayloadResponse $payloadResponse
55
     */
56 1
    protected function handleResponse($payloadResponse)
57
    {
58 1
        if ($payloadResponse->isOk()) {
59 1
            $this->writeOk('Successfully authenticated by the Slack API!');
60 1
            if ($this->output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL) {
61
                $data = [
62 1
                    'User ID'  => $payloadResponse->getUserId(),
63 1
                    'Username' => $payloadResponse->getUsername(),
64 1
                    'Team ID'  => $payloadResponse->getTeamId(),
65 1
                    'Team'     => $payloadResponse->getTeam(),
66 1
                ];
67 1
                $this->renderKeyValueTable($data);
68 1
            }
69 1
        } else {
70 1
            $this->writeError(sprintf('Failed to be authenticated by the Slack API: %s', lcfirst($payloadResponse->getErrorExplanation())));
71
72 1
            return 1;
73
        }
74 1
    }
75
}
76