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.

ImCloseCommand   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 3
Dependencies 5

Importance

Changes 5
Bugs 1 Features 0
Metric Value
wmc 5
c 5
b 1
f 0
lcom 3
cbo 5
dl 0
loc 50
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 15 1
A createPayload() 0 7 1
A handleResponse() 0 12 3
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\ImClosePayload;
15
use CL\Slack\Payload\ImClosePayloadResponse;
16
use Symfony\Component\Console\Input\InputArgument;
17
use Symfony\Component\Console\Input\InputInterface;
18
19
/**
20
 * @author Cas Leentfaar <[email protected]>
21
 */
22
class ImCloseCommand extends AbstractApiCommand
23
{
24
    /**
25
     * {@inheritDoc}
26
     */
27
    protected function configure()
28
    {
29
        parent::configure();
30
31
        $this->setName('im:close');
32
        $this->setDescription('Closes a given Slack IM channel');
33
        $this->addArgument('im-id', InputArgument::REQUIRED, 'The ID of an IM channel to close');
34
        $this->setHelp(<<<EOT
35
The <info>im:close</info> command let's you close a IM channel
36
37
For more information about the related API method, check out the official documentation:
38
<comment>https://api.slack.com/methods/im.close</comment>
39
EOT
40
        );
41
    }
42
43
    /**
44
     * @return ImClosePayload
45
     */
46
    protected function createPayload()
47
    {
48
        $payload = new ImClosePayload();
49
        $payload->setImId($this->input->getArgument('im-id'));
50
51
        return $payload;
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     *
57
     * @param ImClosePayloadResponse $payloadResponse
58
     */
59
    protected function handleResponse($payloadResponse)
60
    {
61
        if ($payloadResponse->isOk()) {
62
            if ($payloadResponse->isAlreadyClosed()) {
63
                $this->output->writeln('<comment>Couldn\'t close IM channel: the channel has already been closed</comment>');
64
            } else {
65
                $this->writeOk('Successfully closed IM channel!');
66
            }
67
        } else {
68
            $this->writeError(sprintf('Failed to close IM channel: %s', lcfirst($payloadResponse->getErrorExplanation())));
69
        }
70
    }
71
}
72