Completed
Pull Request — master (#13)
by
unknown
03:54
created

MockClient::sendAsyncRequest()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 1
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ElevenLabs\Api\Service\Tests\Functional;
6
7
use Http\Mock\Client;
8
use Http\Promise\FulfilledPromise;
9
use Http\Promise\RejectedPromise;
10
use Psr\Http\Message\RequestInterface;
11
12
/**
13
 * Class MockClient.
14
 */
15
class MockClient extends Client
16
{
17
    /**
18
     * @param RequestInterface $request
19
     *
20
     * @throws \Http\Client\Exception
21
     *
22
     * @return \Http\Client\Promise\HttpFulfilledPromise|\Http\Client\Promise\HttpRejectedPromise|FulfilledPromise|RejectedPromise
23
     */
24
    public function sendAsyncRequest(RequestInterface $request)
25
    {
26
        try {
27
            return new FulfilledPromise($this->sendRequest($request));
28
        } catch (\Exception $e) {
29
            return new RejectedPromise($e);
30
        }
31
    }
32
}
33