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.

FilesInfoCommand   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 4

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 22 1
A createPayload() 0 9 1
A handleResponse() 0 9 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\FilesInfoPayload;
15
use CL\Slack\Payload\FilesInfoPayloadResponse;
16
use Symfony\Component\Console\Input\InputArgument;
17
use Symfony\Component\Console\Input\InputOption;
18
19
/**
20
 * @author Cas Leentfaar <[email protected]>
21
 */
22
class FilesInfoCommand extends AbstractApiCommand
23
{
24
    /**
25
     * {@inheritDoc}
26
     */
27
    protected function configure()
28
    {
29
        parent::configure();
30
31
        $this->setName('files:info');
32
        $this->setDescription('Returns information about a file in your Slack team');
33
        $this->addArgument('file-id', InputArgument::REQUIRED, 'The ID of the file to get information on');
34
        $this->addOption('count', 'c', InputOption::VALUE_REQUIRED, 'Number of items to return per page.');
35
        $this->addOption('page', 'p', InputOption::VALUE_REQUIRED, 'Page number of results to return.');
36
        $this->setHelp(<<<EOT
37
The <info>files:info</info> command returns information about a file in your team.
38
39
Each comment object in the comments array contains details about a single comment. Comments are returned oldest first.
40
41
The paging information contains the count of comments returned, the total number of comments, the page of results
42
returned in this response and the total number of pages available.
43
44
For more information about the related API method, check out the official documentation:
45
<comment>https://api.slack.com/methods/files.info</comment>
46
EOT
47
        );
48
    }
49
50
    /**
51
     * @return FilesInfoPayload
52
     */
53
    protected function createPayload()
54
    {
55
        $payload = new FilesInfoPayload();
56
        $payload->setFileId($this->input->getArgument('file-id'));
57
        $payload->setCount($this->input->getOption('count'));
58
        $payload->setPage($this->input->getOption('page'));
59
60
        return $payload;
61
    }
62
63
    /**
64
     * {@inheritdoc}
65
     *
66
     * @param FilesInfoPayloadResponse $payloadResponse
67
     */
68
    protected function handleResponse($payloadResponse)
69
    {
70
        if ($payloadResponse->isOk()) {
71
            $file = $payloadResponse->getFile();
72
            $this->renderKeyValueTable($file);
73
        } else {
74
            $this->writeError(sprintf('Failed to fetch information about the file: %s', lcfirst($payloadResponse->getErrorExplanation())));
75
        }
76
    }
77
}
78