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 ( 537896...626fac )
by Cees-Jan
02:23
created

CallAsyncTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 27
ccs 12
cts 12
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
getTransport() 0 1 ?
A callAsync() 0 9 1
A observableToPromise() 0 4 1
A wait() 0 7 1
1
<?php
2
declare(strict_types=1);
3
4
namespace WyriHaximus\ApiClient\Resource;
5
6
use function Clue\React\Block\await;
7
use React\Promise\PromiseInterface;
8
use Rx\ObservableInterface;
9
use Rx\React\Promise;
10
use WyriHaximus\ApiClient\Transport\Client;
11
12
trait CallAsyncTrait
13
{
14
    abstract protected function getTransport(): Client;
15
16 1
    protected function callAsync(string $function, ...$args)
17
    {
18 1
        $classChunks = explode('\\', get_class($this));
19 1
        $class = array_pop($classChunks);
20 1
        return $this->getTransport()
21 1
            ->getHydrator()
22 1
            ->buildAsyncFromSync($class, $this)
23 1
            ->$function(...$args);
24
    }
25
26 1
    protected function observableToPromise(ObservableInterface $observable): PromiseInterface
27
    {
28 1
        return Promise::fromObservable($observable);
29
    }
30
31 1
    protected function wait(PromiseInterface $promise)
32
    {
33 1
        return await(
34
            $promise,
35 1
            $this->getTransport()->getLoop()
36
        );
37
    }
38
}
39