Completed
Push — master ( 412356...c961c9 )
by Stéphane
18s queued 12s
created

ReactFactory::buildHttpClient04()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 18
ccs 0
cts 7
cp 0
rs 9.6666
c 0
b 0
f 0
cc 3
nc 4
nop 2
crap 12
1
<?php
2
3
namespace Http\Adapter\React;
4
5
use React\EventLoop\LoopInterface;
6
use React\EventLoop\Factory as EventLoopFactory;
7
use React\Http\Browser;
8
use React\Socket\ConnectorInterface;
9
10
/**
11
 * Factory wrapper for React instances.
12
 *
13
 * @author Stéphane Hulard <[email protected]>
14
 */
15
class ReactFactory
16
{
17
    /**
18
     * Build a react Event Loop.
19
     */
20
    public static function buildEventLoop(): LoopInterface
21
    {
22
        return EventLoopFactory::create();
23
    }
24
25
    /**
26 106
     * Build a React Http Client.
27
     *
28 106
     * @param ConnectorInterface|null $connector Only pass this argument if you need to customize DNS
29
     *                                           behaviour.
30
     */
31
    public static function buildHttpClient(
32
        LoopInterface $loop,
33
        ConnectorInterface $connector = null
34
    ): Browser {
35
        return (new Browser($loop, $connector))
36
            ->withRejectErrorResponse(false)
37
            ->withFollowRedirects(false);
38
    }
39
}
40