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.

ChannelsRenameCommand   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 3
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 5
c 4
b 0
f 0
lcom 3
cbo 5
dl 0
loc 56
ccs 25
cts 25
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 19 1
A createPayload() 0 8 1
A handleResponse() 0 13 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\ChannelsRenamePayload;
15
use CL\Slack\Payload\ChannelsRenamePayloadResponse;
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 ChannelsRenameCommand extends AbstractApiCommand
23
{
24
    /**
25
     * {@inheritDoc}
26
     */
27 1
    protected function configure()
28
    {
29 1
        parent::configure();
30
31 1
        $this->setName('channels:rename');
32 1
        $this->setDescription('Leave a channel (as the user of the token).');
33 1
        $this->addArgument('channel-id', InputArgument::REQUIRED, 'The ID of the channel to rename');
34 1
        $this->addArgument('name', InputArgument::REQUIRED, 'The new name for this channel');
35 1
        $this->setHelp(<<<EOT
36
The <info>channels:rename</info> command renames a team channel.
37
38
The only people who can rename a channel are team admins, or the person that originally created the channel.
39
Others will receive a "not_authorized" error.
40
41
For more information about the related API method, check out the official documentation:
42
<comment>https://api.slack.com/methods/channels.rename</comment>
43
EOT
44 1
        );
45 1
    }
46
47
    /**
48
     * @return ChannelsRenamePayload
49
     */
50 1
    protected function createPayload()
51
    {
52 1
        $payload = new ChannelsRenamePayload();
53 1
        $payload->setChannelId($this->input->getArgument('channel-id'));
54 1
        $payload->setName($this->input->getArgument('name'));
55
56 1
        return $payload;
57
    }
58
59
    /**
60
     * {@inheritdoc}
61
     *
62
     * @param ChannelsRenamePayloadResponse $payloadResponse
63
     */
64 1
    protected function handleResponse($payloadResponse)
65
    {
66 1
        if ($payloadResponse->isOk()) {
67 1
            $this->writeOk('Successfully renamed channel!');
68 1
            if ($this->output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL) {
69 1
                $this->output->writeln('Renamed channel:');
70 1
                $data = $this->serializeObjectToArray($payloadResponse->getChannel());
71 1
                $this->renderKeyValueTable($data);
72 1
            }
73 1
        } else {
74 1
            $this->writeError(sprintf('Failed to rename channel: %s', lcfirst($payloadResponse->getErrorExplanation())));
75
        }
76 1
    }
77
}
78