Completed
Pull Request — master (#1)
by Márk
04:37
created

HttpClientEmulator::sendRequest()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4286
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Http\Client\Common;
4
5
use Psr\Http\Message\RequestInterface;
6
7
/**
8
 * Emulates an HTTP Client in an HTTP Async Client.
9
 *
10
 * @author Márk Sági-Kazár <[email protected]>
11
 */
12
trait HttpClientEmulator
13
{
14
    /**
15
     * {@inheritdoc}
16
     *
17
     * @see HttpClient::sendRequest
18
     */
19 2
    public function sendRequest(RequestInterface $request)
20
    {
21 2
        $promise = $this->sendAsyncRequest($request);
22
23 2
        return $promise->wait();
24
    }
25
26
    /**
27
     * {@inheritdoc}
28
     *
29
     * @see HttpAsyncClient::sendAsyncRequest
30
     */
31
    abstract public function sendAsyncRequest(RequestInterface $request);
32
}
33