|
6 | 6 | use React\Dns\Model\Message; |
7 | 7 | use React\Dns\Protocol\Parser; |
8 | 8 | use React\Dns\Protocol\BinaryDumper; |
| 9 | +use React\EventLoop\Loop; |
9 | 10 | use React\EventLoop\LoopInterface; |
10 | 11 | use React\Promise\Deferred; |
11 | 12 | use Clue\React\Multicast\Factory as DatagramFactory; |
|
21 | 22 | */ |
22 | 23 | class MulticastExecutor implements ExecutorInterface |
23 | 24 | { |
| 25 | + /** @var LoopInterface */ |
24 | 26 | private $loop; |
| 27 | + |
| 28 | + /** @var Parser */ |
25 | 29 | private $parser; |
| 30 | + |
| 31 | + /** @var BinaryDumper */ |
26 | 32 | private $dumper; |
| 33 | + |
| 34 | + /** @var number */ |
27 | 35 | private $timeout; |
| 36 | + |
| 37 | + /** @var DatagramFactory */ |
28 | 38 | private $factory; |
29 | 39 |
|
30 | | - public function __construct(LoopInterface $loop, Parser $parser = null, BinaryDumper $dumper = null, $timeout = 5, DatagramFactory $factory = null) |
| 40 | + /** |
| 41 | + * @param ?LoopInterface $loop |
| 42 | + * @param ?Parser $parser |
| 43 | + * @param ?BinaryDumper $dumper |
| 44 | + * @param number $timeout |
| 45 | + * @param ?DatagramFactory $factory |
| 46 | + */ |
| 47 | + public function __construct(LoopInterface $loop = null, Parser $parser = null, BinaryDumper $dumper = null, $timeout = 5, DatagramFactory $factory = null) |
31 | 48 | { |
32 | | - if ($parser === null) { |
33 | | - $parser = new Parser(); |
34 | | - } |
35 | | - if ($dumper === null) { |
36 | | - $dumper = new BinaryDumper(); |
37 | | - } |
38 | | - if ($factory === null) { |
39 | | - $factory = new DatagramFactory($loop); |
40 | | - } |
41 | | - |
42 | | - $this->loop = $loop; |
43 | | - $this->parser = $parser; |
44 | | - $this->dumper = $dumper; |
| 49 | + $this->loop = $loop ?: Loop::get(); |
| 50 | + $this->parser = $parser ?: new Parser(); |
| 51 | + $this->dumper = $dumper ?: new BinaryDumper(); |
45 | 52 | $this->timeout = $timeout; |
46 | | - $this->factory = $factory; |
| 53 | + $this->factory = $factory ?: new DatagramFactory($this->loop); |
47 | 54 | } |
48 | 55 |
|
49 | 56 | public function query($nameserver, Query $query) |
|
0 commit comments