Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
CRAP | n/a |
0 / 0 |
|
| Clansuite\Capture\createCaptureService | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php declare(strict_types=1); |
| 2 | |
| 3 | /** |
| 4 | * Clansuite Server Query |
| 5 | * |
| 6 | * SPDX-FileCopyrightText: 2003-2025 Jens A. Koch |
| 7 | * SPDX-License-Identifier: MIT |
| 8 | * |
| 9 | * For the full copyright and license information, please view |
| 10 | * the LICENSE file that was distributed with this source code. |
| 11 | */ |
| 12 | |
| 13 | namespace Clansuite\Capture; |
| 14 | |
| 15 | use Clansuite\Capture\Extractor\VersionNormalizer; |
| 16 | use Clansuite\Capture\Protocol\ProtocolResolver; |
| 17 | use Clansuite\Capture\Storage\JsonFixtureStorage; |
| 18 | use Clansuite\Capture\Strategy\DirectCaptureStrategy; |
| 19 | use Clansuite\Capture\Strategy\WorkerCaptureStrategy; |
| 20 | use Clansuite\ServerQuery\ServerProtocols; |
| 21 | |
| 22 | function createCaptureService(): CaptureService |
| 23 | { |
| 24 | /** |
| 25 | * @var array{ |
| 26 | * fixtures_dir: string, |
| 27 | * default_timeout: int, |
| 28 | * worker_timeout: int, |
| 29 | * use_worker: bool |
| 30 | * } |
| 31 | */ |
| 32 | $config = require __DIR__ . '/../../config/capture_config.php'; |
| 33 | |
| 34 | $storage = new JsonFixtureStorage($config['fixtures_dir']); |
| 35 | $resolver = new ProtocolResolver(ServerProtocols::getProtocolsMap()); |
| 36 | $strategy = $config['use_worker'] |
| 37 | ? new WorkerCaptureStrategy($config['worker_timeout']) |
| 38 | : new DirectCaptureStrategy; |
| 39 | $normalizer = new VersionNormalizer; |
| 40 | |
| 41 | return new CaptureService($resolver, $strategy, $storage, $normalizer); |
| 42 | } |