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   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 4
c 4
b 0
f 0
lcom 2
cbo 4
dl 0
loc 52
ccs 22
cts 22
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 19 1
A createPayload() 0 9 1
A handleResponse() 0 8 2
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