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.
Completed
Push — master ( 6ac76d...bfd754 )
by Cees-Jan
03:25
created

Config   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%
Metric Value
dl 35
loc 35
ccs 17
cts 17
cp 1
rs 10
wmc 4
lcom 0
cbo 3

1 Method

Rating   Name   Duplication   Size   Complexity  
B handle() 30 30 4

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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 4
    public function handle(ConnectionContext $context, string $line): PromiseInterface
25
    {
26 4
        if ($line === '') {
27 2
            $context->quit();
28 2
            return reject();
29
        }
30
31 3
        $plugin = $this->getNode()->getPlugin($line);
32
33 3
        if ($plugin === false) {
34 1
            $context->quit();
35 1
            return reject();
36
        }
37
38 2
        return $plugin->getConfiguration()->then(
39
            function ($configuration) {
40 2
                $lines = [];
41 2
                foreach ($configuration->getPairs() as $pair) {
42 2
                    $lines[] = $pair->getKey() . ' ' . $pair->getValue();
43
                }
44 2
                $lines[] = '.';
45 2
                return resolve($lines);
46 2
            },
47 2
            function () {
48
                return resolve([
49
                    '.',
50
                ]);
51 2
            }
52
        );
53
    }
54
}
55