Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
DirectCaptureStrategy
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 capture
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
1 / 1
1
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
13namespace Clansuite\Capture\Strategy;
14
15use function time;
16use Clansuite\Capture\CaptureResult;
17use Clansuite\Capture\Protocol\ProtocolInterface;
18use Clansuite\Capture\ServerAddress;
19use Override;
20
21/**
22 * Capture strategy that performs server queries directly without using worker processes.
23 */
24final class DirectCaptureStrategy implements CaptureStrategyInterface
25{
26    /**
27     * capture method.
28     *
29     * @param array<mixed> $options
30     */
31    #[Override]
32    public function capture(ProtocolInterface $protocol, ServerAddress $addr, array $options): CaptureResult
33    {
34        // Stub: query and return result without actual capture
35        $serverInfo = $protocol->query($addr);
36        $rawPackets = []; // TODO: capture packets
37        $metadata   = [
38            'ip'        => $addr->ip,
39            'port'      => $addr->port,
40            'protocol'  => $protocol->getProtocolName(),
41            'timestamp' => time(),
42        ];
43
44        return new CaptureResult($rawPackets, $serverInfo, $metadata);
45    }
46}