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 ( a55f05...bfb702 )
by Cees-Jan
01:23 queued 24s
created

JsonEncodeService   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 88.89%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 30
ccs 8
cts 9
cp 0.8889
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A encode() 0 10 2
1
<?php declare(strict_types=1);
2
3
namespace ApiClients\Tools\Json;
4
5
use ApiClients\Foundation\Service\ServiceInterface;
6
use React\EventLoop\LoopInterface;
7
use React\Promise\CancellablePromiseInterface;
8
use function ExceptionalJSON\encode;
9
use function React\Promise\resolve;
10
use function WyriHaximus\React\futureFunctionPromise;
11
12
final class JsonEncodeService
13
{
14
    /**
15
     * @var LoopInterface
16
     */
17
    private $loop;
18
19
    /**
20
     * @param LoopInterface $loop
21
     */
22 2
    public function __construct(LoopInterface $loop)
23
    {
24 2
        $this->loop = $loop;
25 2
    }
26
27
    /**
28
     * @param array $input
29
     * @return CancellablePromiseInterface
30
     */
31 2
    public function encode(array $input): CancellablePromiseInterface
32
    {
33 2
        if (!is_array($input)) {
34
            return resolve($input);
35
        }
36
37 2
        return futureFunctionPromise($this->loop, $input, function ($json) {
38 2
            return encode($json);
39 2
        });
40
    }
41
}
42