1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
namespace ApiClients\Client\Twitter; |
4
|
|
|
|
5
|
|
|
use ApiClients\Client\Twitter\Resource\TweetInterface; |
6
|
|
|
use ApiClients\Client\Twitter\Resource\UserInterface; |
7
|
|
|
use React\EventLoop\Factory as LoopFactory; |
8
|
|
|
use function Clue\React\Block\await; |
9
|
|
|
use React\EventLoop\LoopInterface; |
10
|
|
|
|
11
|
|
|
final class Client implements ClientInterface |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* @var LoopInterface |
15
|
|
|
*/ |
16
|
|
|
protected $loop; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @var AsyncClient |
20
|
|
|
*/ |
21
|
|
|
protected $client; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @var StreamingClient |
25
|
|
|
*/ |
26
|
|
|
protected $streamingClient; |
27
|
|
|
|
28
|
|
|
public function __construct( |
29
|
|
|
string $consumerKey, |
30
|
|
|
string $consumerSecret |
31
|
|
|
) { |
32
|
|
|
$this->loop = LoopFactory::create(); |
33
|
|
|
$this->client = new AsyncClient($consumerKey, $consumerSecret, $this->loop); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function withAccessToken(string $accessToken, string $accessTokenSecret): Client |
37
|
|
|
{ |
38
|
|
|
$clone = clone $this; |
39
|
|
|
$clone->client = $this->client->withAccessToken($accessToken, $accessTokenSecret); |
40
|
|
|
return $clone; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public function withOutAccessToken(): Client |
44
|
|
|
{ |
45
|
|
|
$clone = clone $this; |
46
|
|
|
$clone->client = $this->client->withOutAccessToken(); |
47
|
|
|
return $clone; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function stream(): StreamingClient |
51
|
|
|
{ |
52
|
|
|
if (!($this->streamingClient instanceof StreamingClient)) { |
53
|
|
|
$this->streamingClient = new StreamingClient( |
54
|
|
|
$this->loop, |
55
|
|
|
$this->client->getCommandBus(), |
56
|
|
|
$this->client->stream() |
57
|
|
|
); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
return $this->streamingClient; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
public function tweet(string $tweet): TweetInterface |
64
|
|
|
{ |
65
|
|
|
return await( |
66
|
|
|
$this->client->tweet($tweet), |
|
|
|
|
67
|
|
|
$this->loop |
68
|
|
|
); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
public function user(string $tweet): UserInterface |
72
|
|
|
{ |
73
|
|
|
return await( |
74
|
|
|
$this->client->user($tweet), |
75
|
|
|
$this->loop |
76
|
|
|
); |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|
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.