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.

ChannelsJoinCommand   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 3
Dependencies 5

Test Coverage

Coverage 96%

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 6
c 4
b 0
f 0
lcom 3
cbo 5
dl 0
loc 59
ccs 24
cts 25
cp 0.96
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 19 1
A createPayload() 0 7 1
A handleResponse() 0 17 4
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\ChannelsJoinPayload;
15
use CL\Slack\Payload\ChannelsJoinPayloadResponse;
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 ChannelsJoinCommand extends AbstractApiCommand
23
{
24
    /**
25
     * {@inheritDoc}
26
     */
27 1
    protected function configure()
28
    {
29 1
        parent::configure();
30
31 1
        $this->setName('channels:join');
32 1
        $this->setDescription('Joins a channel with the token\'s user (creates channel if it doesn\'t exist)');
33 1
        $this->addArgument('channel', InputArgument::REQUIRED, 'The name of the channel to join (or create if it doesn\'t exist yet)');
34 1
        $this->setHelp(<<<EOT
35
The <info>channels.join</info> command is used to join a channel.
36
If the channel does not exist, it is created.
37
38
Unlike the other channels-commands, this command requires you to supply the NAME instead of the ID of the channel,
39
because the channel might be created if it doesn't exist yet.
40
41
For more information about the related API method, check out the official documentation:
42
<comment>https://api.slack.com/methods/channels.join</comment>
43
EOT
44 1
        );
45 1
    }
46
47
    /**
48
     * @return ChannelsJoinPayload
49
     */
50 1
    protected function createPayload()
51
    {
52 1
        $payload = new ChannelsJoinPayload();
53 1
        $payload->setName($this->input->getArgument('channel'));
54
55 1
        return $payload;
56
    }
57
58
    /**
59
     * {@inheritdoc}
60
     *
61
     * @param ChannelsJoinPayloadResponse $payloadResponse
62
     */
63 1
    protected function handleResponse($payloadResponse)
64
    {
65 1
        if ($payloadResponse->isOk()) {
66 1
            if ($this->output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL) {
67 1
                if ($payloadResponse->isAlreadyInChannel()) {
68 1
                    $this->writeError('You are already in this channel:');
69 1
                } else {
70
                    $this->writeOk('Successfully joined channel:');
71
                }
72
73 1
                $data = $this->serializeObjectToArray($payloadResponse->getChannel());
74 1
                $this->renderKeyValueTable($data);
75 1
            }
76 1
        } else {
77 1
            $this->writeError(sprintf('Failed to join channel: %s', lcfirst($payloadResponse->getErrorExplanation())));
78
        }
79 1
    }
80
}
81