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.

UsersListCommand::handleResponse()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 15
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
c 4
b 0
f 0
dl 0
loc 15
rs 9.4285
cc 3
eloc 11
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\UsersListPayload;
15
use CL\Slack\Payload\UsersListPayloadResponse;
16
17
/**
18
 * @author Cas Leentfaar <[email protected]>
19
 */
20
class UsersListCommand extends AbstractApiCommand
21
{
22
    /**
23
     * {@inheritDoc}
24
     */
25
    protected function configure()
26
    {
27
        parent::configure();
28
29
        $this->setName('users:list');
30
        $this->setDescription('Returns a list of all users in the team (including deleted/deactivated users)');
31
        $this->setHelp(<<<EOT
32
The <info>users:list</info> command returns a list of all users in the team. This includes deleted/deactivated users.
33
34
For more information about the related API method, check out the official documentation:
35
<comment>https://api.slack.com/methods/users.list</comment>
36
EOT
37
        );
38
    }
39
40
    /**
41
     * @return UsersListPayload
42
     */
43
    protected function createPayload()
44
    {
45
        $payload = new UsersListPayload();
46
47
        return $payload;
48
    }
49
50
    /**
51
     * {@inheritdoc}
52
     *
53
     * @param UsersListPayloadResponse $payloadResponse
54
     */
55
    protected function handleResponse($payloadResponse)
56
    {
57
        if ($payloadResponse->isOk()) {
58
            $users = $payloadResponse->getUsers();
59
            $this->output->writeln(sprintf('Received <comment>%d</comment> users...', count($users)));
60
            if (!empty($users)) {
61
                $this->renderTable($users, null);
62
                $this->writeOk('Successfully listed users');
63
            } else {
64
                $this->writeError('No users seem to be assigned to your team... this is strange...');
65
            }
66
        } else {
67
            $this->writeError(sprintf('Failed to list users: %s', lcfirst($payloadResponse->getErrorExplanation())));
68
        }
69
    }
70
}
71