Test Setup Failed
Pull Request — master (#2)
by Solo
02:21 queued 10s
created

OAuth2ClientTrait::delete2()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 3
1
<?php
2
3
namespace mpyw\Cowitter\Traits;
4
5
use mpyw\Co\CoInterface;
6
use mpyw\Cowitter\Helpers\CurlExecutor;
7
8
trait OAuth2ClientTrait
9
{
10
    abstract public function withCredentials(array $credentails);
11
    abstract protected function getInternalCredential();
12
    abstract protected function getInternalCurl();
13
14
    public function oauthForBearerToken()
15
    {
16
        $obj = CurlExecutor::execDecoded($this->getInternalCurl()->oauthForBearerToken());
17
        return $this->withCredentials([
18
            $this->getInternalCredential()['consumer_key'],
19
            $this->getInternalCredential()['consumer_secret'],
20
            $obj->access_token,
21
            '',
22
        ]);
23
    }
24
25
    public function oauthForBearerTokenAsync()
26
    {
27
        $obj = (yield CurlExecutor::execDecodedAsync($this->getInternalCurl()->oauthForBearerToken()));
28
        yield CoInterface::RETURN_WITH => $this->withCredentials([
29
            $this->getInternalCredential()['consumer_key'],
30
            $this->getInternalCredential()['consumer_secret'],
31
            $obj->access_token,
32
            '',
33
        ]);
34
        // @codeCoverageIgnoreStart
35
    }
36
    // @codeCoverageIgnoreEnd
37
38
    public function invalidateBearerToken()
39
    {
40
        CurlExecutor::execDecoded($this->getInternalCurl()->invalidateBearerToken());
41
    }
42
43
    public function invalidateBearerTokenAsync()
44
    {
45
        yield CurlExecutor::execDecodedAsync($this->getInternalCurl()->invalidateBearerToken());
46
    }
47
48
    public function get2($endpoint, array $params = [], $return_response_object = false)
49
    {
50
        return CurlExecutor::execDecoded($this->getInternalCurl()->get2($endpoint, $params), $return_response_object);
51
    }
52
53
    public function get2Async($endpoint, array $params = [], $return_response_object = false)
54
    {
55
        yield CoInterface::RETURN_WITH => (yield CurlExecutor::execDecodedAsync($this->getInternalCurl()->get2($endpoint, $params), $return_response_object));
56
        // @codeCoverageIgnoreStart
57
    }
58
    // @codeCoverageIgnoreEnd
59
60
    public function post2($endpoint, array $params = [], $return_response_object = false)
61
    {
62
        return CurlExecutor::execDecoded($this->getInternalCurl()->post2($endpoint, $params), $return_response_object);
63
    }
64
65
    public function post2Async($endpoint, array $params = [], $return_response_object = false)
66
    {
67
        yield CoInterface::RETURN_WITH => (yield CurlExecutor::execDecodedAsync($this->getInternalCurl()->post2($endpoint, $params), $return_response_object));
68
        // @codeCoverageIgnoreStart
69
    }
70
    // @codeCoverageIgnoreEnd
71
72
    public function delete2($endpoint, array $params = [], $return_response_object = false)
73
    {
74
        return CurlExecutor::execDecoded($this->getInternalCurl()->delete2($endpoint, $params), $return_response_object);
75
    }
76
77
    public function delete2Async($endpoint, array $params = [], $return_response_object = false)
78
    {
79
        yield CoInterface::RETURN_WITH => (yield CurlExecutor::execDecodedAsync($this->getInternalCurl()->delete2($endpoint, $params), $return_response_object));
80
        // @codeCoverageIgnoreStart
81
    }
82
    // @codeCoverageIgnoreEnd
83
84
    public function put2($endpoint, array $params = [], $return_response_object = false)
85
    {
86
        return CurlExecutor::execDecoded($this->getInternalCurl()->put2($endpoint, $params), $return_response_object);
87
    }
88
89
    public function put2Async($endpoint, array $params = [], $return_response_object = false)
90
    {
91
        yield CoInterface::RETURN_WITH => (yield CurlExecutor::execDecodedAsync($this->getInternalCurl()->put2($endpoint, $params), $return_response_object));
92
        // @codeCoverageIgnoreStart
93
    }
94
    // @codeCoverageIgnoreEnd
95
}
96