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.

ConfigEditCommand::configure()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 18
ccs 7
cts 7
cp 1
rs 9.4285
cc 1
eloc 7
nc 1
nop 0
crap 1
1
<?php
2
3
namespace CL\SlackCli\Command;
4
5
use CL\SlackCli\Config\Config;
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Output\OutputInterface;
8
9
/**
10
 * @author Cas Leentfaar <[email protected]>
11
 */
12
class ConfigEditCommand extends AbstractCommand
13
{
14
    /**
15
     * {@inheritDoc}
16
     */
17 1
    protected function configure()
18
    {
19 1
        parent::configure();
20
21 1
        $this->setName('config:edit');
22 1
        $this->setDescription('Edit config options');
23
24 1
        $this->setHelp(<<<EOT
25
The <info>config:edit</info> command allows you to edit the Slack CLI settings using a pre-configured editor.
26
27
To choose your editor you can set the "SLACK_CONFIG_EDITOR" environment variable.
28
29
To get a list of configuration values in the file, use the `config:list` command:
30
31
    <comment>slack.phar config:list</comment>
32
EOT
33 1
        );
34 1
    }
35
36
    /**
37
     * {@inheritDoc}
38
     */
39 1
    protected function execute(InputInterface $input, OutputInterface $output)
40
    {
41 1
        $editor = escapeshellcmd(getenv('SLACK_CONFIG_EDITOR'));
42 1
        if (!$editor) {
43
            if (defined('PHP_WINDOWS_VERSION_BUILD')) {
44
                $editor = 'notepad';
45
            } else {
46
                foreach (['vim', 'vi', 'nano', 'pico', 'ed'] as $candidate) {
47
                    if (exec('which ' . $candidate)) {
48
                        $editor = $candidate;
49
                        break;
50
                    }
51
                }
52
            }
53
        }
54
55 1
        $file    = $this->getConfigPath();
56 1
        $to      = defined('PHP_WINDOWS_VERSION_BUILD') ? '' : ' > `tty`';
57 1
        $command = sprintf('%s %s%s', $editor, $file, $to);
58
59 1
        $this->output->writeln(sprintf('Editing `%s` using `%s`...', $file, $editor));
60
61 1
        if (!$this->isTest()) {
62
            system($command);
63
        }
64 1
    }
65
}
66