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.

StarsListCommand::handleResponse()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 18
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 18
rs 9.4285
cc 3
eloc 13
nc 3
nop 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\StarsListPayload;
15
use CL\Slack\Payload\StarsListPayloadResponse;
16
use Symfony\Component\Console\Input\InputOption;
17
18
/**
19
 * @author Cas Leentfaar <[email protected]>
20
 */
21
class StarsListCommand extends AbstractApiCommand
22
{
23
    /**
24
     * {@inheritDoc}
25
     */
26
    protected function configure()
27
    {
28
        parent::configure();
29
30
        $this->setName('stars:list');
31
        $this->setDescription('Returns a list of all the items starred by a user');
32
        $this->addOption('user-id', null, InputOption::VALUE_REQUIRED, 'Show stars by this user. Defaults to the token\'s user.');
33
        $this->setHelp(<<<EOT
34
The <info>stars:list</info> returns a list of all the items starred by a user.
35
36
For more information about the related API method, check out the official documentation:
37
<comment>https://api.slack.com/methods/stars.list</comment>
38
EOT
39
        );
40
    }
41
42
    /**
43
     * @return StarsListPayload
44
     */
45
    protected function createPayload()
46
    {
47
        $payload = new StarsListPayload();
48
        $payload->setUserId($this->input->getOption('user-id'));
49
50
        return $payload;
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     *
56
     * @param StarsListPayloadResponse $payloadResponse
57
     */
58
    protected function handleResponse($payloadResponse)
59
    {
60
        if ($payloadResponse->isOk()) {
61
            $stars = $payloadResponse->getItems();
62
            $this->output->writeln(sprintf('Received <comment>%d</comment> starred items...', count($stars)));
63
            if (!empty($stars)) {
64
                $this->renderTable($stars, null);
65
                $this->writeOk('Finished listing starred items');
66
            } else {
67
                $this->writeComment('No starred items to list');
68
            }
69
        } else {
70
            $this->writeError(sprintf(
71
                'Failed to list starred items: %s',
72
                lcfirst($payloadResponse->getErrorExplanation())
73
            ));
74
        }
75
    }
76
}
77