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.

ChannelsInviteCommand::handleResponse()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 3

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 13
ccs 11
cts 11
cp 1
rs 9.4285
cc 3
eloc 9
nc 3
nop 1
crap 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\ChannelsInvitePayload;
15
use CL\Slack\Payload\ChannelsInvitePayloadResponse;
16
use Symfony\Component\Console\Input\InputArgument;
17
use Symfony\Component\Console\Output\OutputInterface;
18
19
/**
20
 * @author Cas Leentfaar <[email protected]>
21
 */
22
class ChannelsInviteCommand extends AbstractApiCommand
23
{
24
    /**
25
     * {@inheritDoc}
26
     */
27 1
    protected function configure()
28
    {
29 1
        parent::configure();
30
31 1
        $this->setName('channels:invite');
32 1
        $this->setDescription('Invites a user to a channel. The calling user must be a member of the channel.');
33 1
        $this->addArgument('channel-id', InputArgument::REQUIRED, 'The ID of the channel to invite the user to');
34 1
        $this->addArgument('user-id', InputArgument::REQUIRED, 'The ID of the user to invite');
35 1
        $this->setHelp(<<<EOT
36
The <info>channels.invite</info> command is used to invite a user to a channel.
37
The calling user must be a member of the channel.
38
39
For more information about the related API method, check out the official documentation:
40
<comment>https://api.slack.com/methods/channels.invite</comment>
41
EOT
42 1
        );
43 1
    }
44
45
    /**
46
     * @return ChannelsInvitePayload
47
     */
48 1
    protected function createPayload()
49
    {
50 1
        $payload = new ChannelsInvitePayload();
51 1
        $payload->setChannelId($this->input->getArgument('channel-id'));
52 1
        $payload->setUserId($this->input->getArgument('user-id'));
53
54 1
        return $payload;
55
    }
56
57
    /**
58
     * {@inheritdoc}
59
     *
60
     * @param ChannelsInvitePayloadResponse $payloadResponse
61
     */
62 1
    protected function handleResponse($payloadResponse)
63
    {
64 1
        if ($payloadResponse->isOk()) {
65 1
            $this->writeOk('Successfully invited user to the channel!');
66 1
            if ($this->output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL) {
67 1
                $this->output->writeln('Channel used:');
68 1
                $data = $this->serializeObjectToArray($payloadResponse->getChannel());
69 1
                $this->renderKeyValueTable($data);
70 1
            }
71 1
        } else {
72 1
            $this->writeError(sprintf('Failed to invite user to this channel: %s', lcfirst($payloadResponse->getErrorExplanation())));
73
        }
74 1
    }
75
}
76