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.

GroupsRenameCommand   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 3
Dependencies 5

Importance

Changes 5
Bugs 1 Features 0
Metric Value
wmc 5
c 5
b 1
f 0
lcom 3
cbo 5
dl 0
loc 56
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\GroupsRenamePayload;
15
use CL\Slack\Payload\GroupsRenamePayloadResponse;
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 GroupsRenameCommand extends AbstractApiCommand
23
{
24
    /**
25
     * {@inheritDoc}
26
     */
27
    protected function configure()
28
    {
29
        parent::configure();
30
31
        $this->setName('groups:rename');
32
        $this->setDescription('Leave a group (as the user of the token).');
33
        $this->addArgument('group-id', InputArgument::REQUIRED, 'The ID of the group to rename');
34
        $this->addArgument('name', InputArgument::REQUIRED, 'The new name for this group');
35
        $this->setHelp(<<<EOT
36
The <info>groups:rename</info> command renames a team group.
37
38
The only people who can rename a group are team admins, or the person that originally created the group.
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/groups.rename</comment>
43
EOT
44
        );
45
    }
46
47
    /**
48
     * @return GroupsRenamePayload
49
     */
50
    protected function createPayload()
51
    {
52
        $payload = new GroupsRenamePayload();
53
        $payload->setGroupId($this->input->getArgument('group-id'));
54
        $payload->setName($this->input->getArgument('name'));
55
56
        return $payload;
57
    }
58
59
    /**
60
     * {@inheritdoc}
61
     *
62
     * @param GroupsRenamePayloadResponse $payloadResponse
63
     */
64
    protected function handleResponse($payloadResponse)
65
    {
66
        if ($payloadResponse->isOk()) {
67
            $this->writeOk('Successfully renamed group!');
68
            if ($this->output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL) {
69
                $this->output->writeln('Renamed group:');
70
                $data = $this->serializeObjectToArray($payloadResponse->getGroup());
71
                $this->renderKeyValueTable($data);
72
            }
73
        } else {
74
            $this->writeError(sprintf('Failed to leave group: %s', lcfirst($payloadResponse->getErrorExplanation())));
75
        }
76
    }
77
}
78