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.

GroupsMarkCommand   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 4

Importance

Changes 5
Bugs 1 Features 0
Metric Value
wmc 4
c 5
b 1
f 0
lcom 2
cbo 4
dl 0
loc 58
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
B configure() 0 26 1
A createPayload() 0 8 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\GroupsMarkPayload;
15
use CL\Slack\Payload\GroupsMarkPayloadResponse;
16
use Symfony\Component\Console\Input\InputArgument;
17
18
/**
19
 * @author Cas Leentfaar <[email protected]>
20
 */
21
class GroupsMarkCommand extends AbstractApiCommand
22
{
23
    /**
24
     * {@inheritDoc}
25
     */
26
    protected function configure()
27
    {
28
        parent::configure();
29
30
        $this->setName('groups:mark');
31
        $this->setDescription('Moves the read cursor in a Slack group');
32
        $this->addArgument('group-id', InputArgument::REQUIRED, 'ID of the group to set reading cursor in.');
33
        $this->addArgument('timestamp', InputArgument::REQUIRED, 'Timestamp of the most recently seen message.');
34
        $this->setHelp(<<<EOT
35
The <info>groups.mark</info> command is used to move the read cursor in a Slack group.
36
37
After running this command, the mark is saved to the database and broadcast via the message server to all open connections
38
for the token's user.
39
40
You should try to avoid running this command too often. When needing to mark a read position, you should set a timer
41
before running the command. In this way, any further updates needed during the timeout will not generate extra calls
42
(just one per channel).
43
44
This is useful for when reading scroll-back history, or following a busy live channel. A timeout of 5 seconds is a good
45
starting point. Be sure to flush these calls on shutdown/logout.
46
47
For more information about the related API method, check out the official documentation:
48
<comment>https://api.slack.com/methods/groups.mark</comment>
49
EOT
50
        );
51
    }
52
53
    /**
54
     * @return GroupsMarkPayload
55
     */
56
    protected function createPayload()
57
    {
58
        $payload = new GroupsMarkPayload();
59
        $payload->setGroupId($this->input->getArgument('group-id'));
60
        $payload->setSlackTimestamp($this->input->getArgument('timestamp'));
61
62
        return $payload;
63
    }
64
65
    /**
66
     * {@inheritdoc}
67
     *
68
     * @param GroupsMarkPayloadResponse $payloadResponse
69
     */
70
    protected function handleResponse($payloadResponse)
71
    {
72
        if ($payloadResponse->isOk()) {
73
            $this->writeOk('Successfully moved the read cursor!');
74
        } else {
75
            $this->writeError(sprintf('Failed to move the read cursor in the group: %s', lcfirst($payloadResponse->getErrorExplanation())));
76
        }
77
    }
78
}
79