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.

ChatUpdateCommand::createPayload()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 9
ccs 6
cts 6
cp 1
rs 9.6666
cc 1
eloc 6
nc 1
nop 0
crap 1
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\ChatUpdatePayload;
15
use CL\Slack\Payload\ChatUpdatePayloadResponse;
16
use Symfony\Component\Console\Input\InputArgument;
17
18
/**
19
 * @author Cas Leentfaar <[email protected]>
20
 */
21
class ChatUpdateCommand extends AbstractApiCommand
22
{
23
    /**
24
     * {@inheritDoc}
25
     */
26 1
    protected function configure()
27
    {
28 1
        parent::configure();
29
30 1
        $this->setName('chat:update');
31 1
        $this->setDescription('Updates a message from a given channel');
32 1
        $this->addArgument('channel-id', InputArgument::REQUIRED, 'The ID of the channel containing the message to be updated');
33 1
        $this->addArgument('timestamp', InputArgument::REQUIRED, 'Timestamp of the message to be updated');
34 1
        $this->addArgument('text', InputArgument::REQUIRED, 'New text for the message, using the default formatting rules');
35 1
        $this->setHelp(<<<EOT
36
The <info>chat:update</info> command updates a message from a given channel.
37
38
The new message uses the default formatting rules, which can be found here: <comment>https://api.slack.com/docs/formatting</comment>
39
40
For more information about the related API method, check out the official documentation:
41
<comment>https://api.slack.com/methods/chat.update</comment>
42
EOT
43 1
        );
44 1
    }
45
46
    /**
47
     * @return ChatUpdatePayload
48
     */
49 1
    protected function createPayload()
50
    {
51 1
        $payload = new ChatUpdatePayload();
52 1
        $payload->setChannelId($this->input->getArgument('channel-id'));
53 1
        $payload->setSlackTimestamp($this->input->getArgument('timestamp'));
54 1
        $payload->setText($this->input->getArgument('text'));
55
56 1
        return $payload;
57
    }
58
59
    /**
60
     * {@inheritdoc}
61
     *
62
     * @param ChatUpdatePayloadResponse $payloadResponse
63
     */
64 1
    protected function handleResponse($payloadResponse)
65
    {
66 1
        if ($payloadResponse->isOk()) {
67 1
            $this->writeOk('Successfully updated message!');
68 1
        } else {
69 1
            $this->writeError(sprintf('Failed to update message: %s', lcfirst($payloadResponse->getErrorExplanation())));
70
        }
71 1
    }
72
}
73