ReactFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 5
c 1
b 0
f 0
dl 0
loc 23
ccs 6
cts 6
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A buildHttpClient() 0 7 1
A buildEventLoop() 0 3 1
1
<?php
2
3
namespace Http\Adapter\React;
4
5
use React\EventLoop\Factory as EventLoopFactory;
6
use React\EventLoop\LoopInterface;
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 110
    public static function buildEventLoop(): LoopInterface
21
    {
22 110
        return EventLoopFactory::create();
23
    }
24
25
    /**
26
     * Build a React Http Client.
27
     *
28
     * @param ConnectorInterface|null $connector only pass this argument if you need to customize DNS
29
     *                                           behaviour
30
     */
31 106
    public static function buildHttpClient(
32
        LoopInterface $loop,
33
        ConnectorInterface $connector = null
34
    ): Browser {
35 106
        return (new Browser($loop, $connector))
36 106
            ->withRejectErrorResponse(false)
37 106
            ->withFollowRedirects(false);
38
    }
39
}
40