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.

GroupsSetTopicCommand::createPayload()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
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\GroupsSetTopicPayload;
15
use CL\Slack\Payload\GroupsSetTopicPayloadResponse;
16
use Symfony\Component\Console\Input\InputArgument;
17
18
/**
19
 * @author Cas Leentfaar <[email protected]>
20
 */
21
class GroupsSetTopicCommand extends AbstractApiCommand
22
{
23
    /**
24
     * {@inheritDoc}
25
     */
26
    protected function configure()
27
    {
28
        parent::configure();
29
30
        $this->setName('groups:set-topic');
31
        $this->setDescription('Change the topic of a group. The calling user must be a member of the group.');
32
        $this->addArgument('group-id', InputArgument::REQUIRED, 'The ID of the group to change the topic of');
33
        $this->addArgument('topic', InputArgument::REQUIRED, 'The new topic');
34
        $this->setHelp(<<<EOT
35
The <info>groups:set-topic</info> command changes the topic of a group.
36
The calling user must be a member of the group.
37
38
For more information about the related API method, check out the official documentation:
39
<comment>https://api.slack.com/methods/groups.setTopic</comment>
40
EOT
41
        );
42
    }
43
44
    /**
45
     * @return GroupsSetTopicPayload
46
     */
47
    protected function createPayload()
48
    {
49
        $payload = new GroupsSetTopicPayload();
50
        $payload->setGroupId($this->input->getArgument('group-id'));
51
        $payload->setTopic($this->input->getArgument('topic'));
52
53
        return $payload;
54
    }
55
56
    /**
57
     * {@inheritdoc}
58
     *
59
     * @param GroupsSetTopicPayloadResponse $payloadResponse
60
     */
61
    protected function handleResponse($payloadResponse)
62
    {
63
        if ($payloadResponse->isOk()) {
64
            $this->writeOk(sprintf('Successfully changed topic of group to: "%s"', $payloadResponse->getTopic()));
65
        } else {
66
            $this->writeError(sprintf('Failed to change topic of group: %s', lcfirst($payloadResponse->getErrorExplanation())));
67
        }
68
    }
69
}
70