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
Pull Request — master (#5)
by Cees-Jan
03:13 queued 01:28
created

Client::tweet()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
1
<?php declare(strict_types=1);
2
3
namespace ApiClients\Client\Twitter;
4
5
use ApiClients\Client\Twitter\Resource\ProfileInterface;
6
use ApiClients\Client\Twitter\Resource\TweetInterface;
7
use ApiClients\Client\Twitter\Resource\UserInterface;
8
use React\EventLoop\Factory as LoopFactory;
9
use React\EventLoop\LoopInterface;
10
use function Clue\React\Block\await;
11
12
final class Client implements ClientInterface
13
{
14
    /**
15
     * @var LoopInterface
16
     */
17
    protected $loop;
18
19
    /**
20
     * @var AsyncClient
21
     */
22
    protected $client;
23
24
    /**
25
     * @var StreamingClient
26
     */
27
    protected $streamingClient;
28
29
    public function __construct(
30
        string $consumerKey,
31
        string $consumerSecret
32
    ) {
33
        $this->loop = LoopFactory::create();
34
        $this->client = new AsyncClient($consumerKey, $consumerSecret, $this->loop);
35
    }
36
37
    public function withAccessToken(string $accessToken, string $accessTokenSecret): Client
38
    {
39
        $clone = clone $this;
40
        $clone->client = $this->client->withAccessToken($accessToken, $accessTokenSecret);
41
        return $clone;
42
    }
43
44
    public function withOutAccessToken(): Client
45
    {
46
        $clone = clone $this;
47
        $clone->client = $this->client->withOutAccessToken();
48
        return $clone;
49
    }
50
51
    public function stream(): StreamingClient
52
    {
53
        if (!($this->streamingClient instanceof StreamingClient)) {
54
            $this->streamingClient = new StreamingClient(
55
                $this->loop,
56
                $this->client->getCommandBus(),
57
                $this->client->stream()
58
            );
59
        }
60
61
        return $this->streamingClient;
62
    }
63
64
    public function tweet(string $tweet): TweetInterface
65
    {
66
        return await(
67
            $this->client->tweet($tweet),
0 ignored issues
show
Bug introduced by
The method tweet() does not seem to exist on object<ApiClients\Client\Twitter\AsyncClient>.

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...
68
            $this->loop
69
        );
70
    }
71
72
    public function profile(): ProfileInterface
73
    {
74
        return await(
75
            $this->client->profile(),
76
            $this->loop
77
        );
78
    }
79
80
    public function user(string $tweet): UserInterface
81
    {
82
        return await(
83
            $this->client->user($tweet),
84
            $this->loop
85
        );
86
    }
87
}
88