Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
RequestMetadataService
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 collectMetadata
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4/**
5 * SPDX-FileCopyrightText: 2026 LibreCode coop and contributors
6 * SPDX-License-Identifier: AGPL-3.0-or-later
7 */
8
9namespace OCA\Libresign\Service;
10
11use OCP\IRequest;
12
13class RequestMetadataService {
14    public function __construct(
15        private IRequest $request,
16    ) {
17    }
18
19    /**
20     * @return array{user-agent: string|null, remote-address: string|null}
21     */
22    public function collectMetadata(): array {
23        return [
24            'user-agent' => $this->request->getHeader('User-Agent'),
25            'remote-address' => $this->request->getRemoteAddress(),
26        ];
27    }
28}