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.

UsersSetPresenceCommand   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 4

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 16 1
A createPayload() 0 7 1
A handleResponse() 0 8 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\UsersSetPresencePayload;
15
use CL\Slack\Payload\UsersSetPresencePayloadResponse;
16
use Symfony\Component\Console\Input\InputArgument;
17
18
/**
19
 * @author Cas Leentfaar <[email protected]>
20
 */
21
class UsersSetPresenceCommand extends AbstractApiCommand
22
{
23
    /**
24
     * {@inheritDoc}
25
     */
26
    protected function configure()
27
    {
28
        parent::configure();
29
30
        $this->setName('users:set-presence');
31
        $this->setDescription('Override the token user\'s presence value');
32
        $this->addArgument('presence', InputArgument::REQUIRED, 'Either "active" or "away"');
33
        $this->setHelp(<<<EOT
34
The <info>users:set-presence</info> command lets you manually override the token user's presence value.
35
Consult the presence documentation for more details.
36
37
For more information about the related API method, check out the official documentation:
38
<comment>https://api.slack.com/methods/presence.set</comment>
39
EOT
40
        );
41
    }
42
43
    /**
44
     * @return UsersSetPresencePayload
45
     */
46
    protected function createPayload()
47
    {
48
        $payload = new UsersSetPresencePayload();
49
        $payload->setPresence($this->input->getArgument('presence'));
50
51
        return $payload;
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     *
57
     * @param UsersSetPresencePayloadResponse $payloadResponse
58
     */
59
    protected function handleResponse($payloadResponse)
60
    {
61
        if ($payloadResponse->isOk()) {
62
            $this->writeOk('Successfully changed presence!');
63
        } else {
64
            $this->writeError(sprintf('Failed to change presence. %s', lcfirst($payloadResponse->getErrorExplanation())));
65
        }
66
    }
67
}
68