Passed
Push — master ( 9b73ba...d26d78 )
by Ryosuke
03:10
created

OAuth2ClientTrait::invalidateBearerTokenAsync()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 4
ccs 4
cts 4
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace mpyw\Cowitter\Traits;
4
5
use mpyw\Co\CoInterface;
6
use mpyw\Cowitter\Helpers\ResponseYielder;
7
8
trait OAuth2ClientTrait
9
{
10
    abstract public function withCredentials(array $credentails);
11
    abstract protected function getInternalCredential();
12
    abstract protected function getInternalCurl();
13
14 1
    public function oauthForBearerToken()
15 1
    {
16 1
        $obj = ResponseYielder::syncExecDecoded($this->getInternalCurl()->oauthForBearerToken());
17 1
        return $this->withCredentials([
18 1
            $this->getInternalCredential()['consumer_key'],
19 1
            $this->getInternalCredential()['consumer_secret'],
20 1
            $obj->access_token,
21 1
            '',
22
        ]);
23
    }
24
25 1
    public function oauthForBearerTokenAsync()
26 1
    {
27 1
        $obj = (yield ResponseYielder::asyncExecDecoded($this->getInternalCurl()->oauthForBearerToken()));
28 1
        yield CoInterface::RETURN_WITH => $this->withCredentials([
29 1
            $this->getInternalCredential()['consumer_key'],
30 1
            $this->getInternalCredential()['consumer_secret'],
31 1
            $obj->access_token,
32 1
            '',
33
        ]);
34
        // @codeCoverageIgnoreStart
35
    }
36
    // @codeCoverageIgnoreEnd
37
38 1
    public function invalidateBearerToken()
39 1
    {
40 1
        ResponseYielder::syncExecDecoded($this->getInternalCurl()->invalidateBearerToken());
41 1
    }
42
43 1
    public function invalidateBearerTokenAsync()
44 1
    {
45 1
        yield ResponseYielder::asyncExecDecoded($this->getInternalCurl()->invalidateBearerToken());
46 1
    }
47
48 1
    public function get2($endpoint, array $params = [], $return_response_object = false)
49 1
    {
50 1
        return ResponseYielder::syncExecDecoded($this->getInternalCurl()->get2($endpoint, $params), $return_response_object);
51
    }
52
53 1
    public function get2Async($endpoint, array $params = [], $return_response_object = false)
54 1
    {
55 1
        return ResponseYielder::asyncExecDecoded($this->getInternalCurl()->get2($endpoint, $params), $return_response_object);
56
    }
57
}
58