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.

Config::handle()   B
last analyzed

Complexity

Conditions 4
Paths 3

Size

Total Lines 30
Code Lines 18

Duplication

Lines 26
Ratio 86.67 %

Code Coverage

Tests 17
CRAP Score 4

Importance

Changes 0
Metric Value
cc 4
eloc 18
nc 3
nop 2
dl 26
loc 30
ccs 17
cts 17
cp 1
crap 4
rs 8.5806
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
/*
5
 * This file is part of PhuninNode.
6
 *
7
 ** (c) 2013 - 2016 Cees-Jan Kiewiet
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
namespace WyriHaximus\PhuninNode\Commands;
14
15
use React\Promise\PromiseInterface;
16
use function React\Promise\reject;
17
use function React\Promise\resolve;
18
use WyriHaximus\PhuninNode\ConnectionContext;
19
20 View Code Duplication
class Config implements CommandInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
21
{
22
    use NodeAwareTrait;
23
24
    /**
25
     * @param ConnectionContext $context
26
     * @param string $line
27
     * @return PromiseInterface
28
     */
29 4
    public function handle(ConnectionContext $context, string $line): PromiseInterface
30
    {
31 4
        if ($line === '') {
32 2
            $context->quit();
33 2
            return reject();
34
        }
35
36 3
        $plugin = $this->getNode()->getPlugin($line);
37
38 3
        if ($plugin === false) {
39 1
            $context->quit();
40 1
            return reject();
41
        }
42
43 2
        return $plugin->getConfiguration()->then(
44
            function ($configuration) {
45 2
                $lines = [];
46 2
                foreach ($configuration->getPairs() as $pair) {
47 2
                    $lines[] = $pair->getKey() . ' ' . $pair->getValue();
48
                }
49 2
                $lines[] = '.';
50 2
                return resolve($lines);
51 2
            },
52 2
            function () {
53
                return resolve([
54
                    '.',
55
                ]);
56 2
            }
57
        );
58
    }
59
}
60