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.

Fetch   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 87.5 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 35
loc 40
ccs 17
cts 17
cp 1
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 3

1 Method

Rating   Name   Duplication   Size   Complexity  
B handle() 26 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 Fetch 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->getValues()->then(
44
            function ($values) {
45 2
                $lines = [];
46 2
                foreach ($values as $value) {
47 2
                    $lines[] = $value->getKey() . '.value ' . str_replace(',', '.', $value->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