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.

ChannelsCreateCommand::createPayload()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 4
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\ChannelsCreatePayload;
15
use CL\Slack\Payload\ChannelsCreatePayloadResponse;
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 ChannelsCreateCommand extends AbstractApiCommand
23
{
24
    /**
25
     * {@inheritDoc}
26
     */
27 1
    protected function configure()
28
    {
29 1
        parent::configure();
30
31 1
        $this->setName('channels:create');
32 1
        $this->setDescription('Creates new Slack channel with the given name');
33 1
        $this->addArgument('name', InputArgument::REQUIRED, 'The name of the channel to create (must not exist already)');
34 1
        $this->setHelp(<<<EOT
35
The <info>channels:create</info> command let's you create a new Slack channel with the given name.
36
37
For more information about the related API method, check out the official documentation:
38
<comment>https://api.slack.com/methods/channels.create</comment>
39
EOT
40 1
        );
41 1
    }
42
43
    /**
44
     * @return ChannelsCreatePayload
45
     */
46 1
    protected function createPayload()
47
    {
48 1
        $payload = new ChannelsCreatePayload();
49 1
        $payload->setName($this->input->getArgument('name'));
50
51 1
        return $payload;
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     *
57
     * @param ChannelsCreatePayloadResponse $payloadResponse
58
     */
59 1
    protected function handleResponse($payloadResponse)
60
    {
61 1
        if ($payloadResponse->isOk()) {
62 1
            $this->writeOk('Successfully created channel!');
63 1
            if ($this->output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL) {
64 1
                $channelData = $this->serializeObjectToArray($payloadResponse->getChannel());
65 1
                $this->renderKeyValueTable($channelData);
66 1
            }
67 1
        } else {
68 1
            $this->writeError(sprintf('Failed to create channel: %s', lcfirst($payloadResponse->getErrorExplanation())));
69
        }
70 1
    }
71
}
72