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::callAsync()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1
Metric Value
dl 0
loc 9
ccs 7
cts 7
cp 1
rs 9.6666
nc 1
cc 1
eloc 7
nop 2
crap 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