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 ( b71509...a4a6e2 )
by Cees-Jan
07:54
created

Repository::refresh()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php declare(strict_types=1);
2
3
namespace ApiClients\Client\Github\Resource\Async;
4
5
use ApiClients\Client\Github\CommandBus\Command\IteratePagesCommand;
6
use ApiClients\Client\Github\Resource\Contents\DirectoryInterface;
7
use ApiClients\Client\Github\Resource\Contents\FileInterface;
8
use ApiClients\Client\Github\Resource\Repository as BaseRepository;
9
use ApiClients\Foundation\Hydrator\CommandBus\Command\HydrateCommand;
10
use ApiClients\Foundation\Transport\CommandBus\Command\JsonEncodeCommand;
11
use ApiClients\Foundation\Transport\CommandBus\Command\RequestCommand;
12
use ApiClients\Foundation\Transport\CommandBus\Command\SimpleRequestCommand;
13
use ApiClients\Foundation\Transport\Response;
14
use GuzzleHttp\Psr7\Request;
15
use React\Promise\PromiseInterface;
16
use Rx\Observable;
17
use Rx\ObservableInterface;
18
use Rx\React\Promise;
19
use function ApiClients\Tools\Rx\unwrapObservableFromPromise;
20
use function React\Promise\resolve;
21
22
class Repository extends BaseRepository
23
{
24
    public function refresh() : Repository
25
    {
26
        return $this->wait($this->callAsync('refresh'));
0 ignored issues
show
Bug introduced by
The method callAsync() does not seem to exist on object<ApiClients\Client...ource\Async\Repository>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
27
    }
28
29
    public function labels(): ObservableInterface
30
    {
31
        return $this->getCommandBus()->handle(
0 ignored issues
show
Bug introduced by
The method getCommandBus() does not seem to exist on object<ApiClients\Client...ource\Async\Repository>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
32
            new IteratePagesCommand('repos/' . $this->fullName() . '/labels')
33
        )->flatMap(function ($response) {
34
            return Observable::fromArray($response);
35
        })->map(function ($label) {
36
            return $this->getCommandBus()->handle(new HydrateCommand('Label', $label));
0 ignored issues
show
Bug introduced by
The method getCommandBus() does not seem to exist on object<ApiClients\Client...ource\Async\Repository>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
37
        });
38
    }
39
40
    public function addLabel(string $name, string $colour): PromiseInterface
0 ignored issues
show
Unused Code introduced by
The parameter $name is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $colour is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
41
    {
42
        return $this->getCommandBus()->handle(
0 ignored issues
show
Bug introduced by
The method getCommandBus() does not seem to exist on object<ApiClients\Client...ource\Async\Repository>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
43
            new JsonEncodeCommand([])
44
        )->then(function (string $json) {
45
            return $this->getCommandBus()->handle(
0 ignored issues
show
Bug introduced by
The method getCommandBus() does not seem to exist on object<ApiClients\Client...ource\Async\Repository>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
46
                new RequestCommand(
47
                    new Request(
48
                        'POST',
49
                        'repos/' . $this->fullName() . '/labels',
50
                        [],
51
                        $json
52
                    )
53
                )
54
            );
55
        })->then(function (Response $response) {
56
            var_export($response->getBody());
57
        });
58
    }
59
60
    public function contents(): Observable
61
    {
62
        return Promise::toObservable($this->handleCommand(
63
            new SimpleRequestCommand('repos/' . $this->fullName() . '/contents/')
64
        ))->flatMap(function ($contents) {
65
            return Observable::fromArray($contents->getBody()->getJson());
66
        })->flatMap(function ($content) {
67
            if ($content['type'] === 'file') {
68
                return Promise::toObservable($this->handleCommand(
69
                    new HydrateCommand(FileInterface::HYDRATE_CLASS, $content)
70
                ));
71
            }
72
73
            return Promise::toObservable($this->handleCommand(
74
                new HydrateCommand(DirectoryInterface::HYDRATE_CLASS, $content)
75
            ));
76
        });
77
    }
78
}
79