Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
1 / 1
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2
3declare(strict_types=1);
4
5/** @license For full copyright and license information, please see the LICENSE.md file. */
6
7namespace App\Modules\Integrations\Infrastructure\Security;
8
9defined('AMMONLY_APP') || exit('Direct script access is forbidden.');
10
11/**
12 * Contract for HTTP client with SSRF protection.
13 *
14 * @package App\Modules\Integrations\Infrastructure\Security
15 */
16interface SsrfProtectionClientInterface
17{
18    /**
19     * Executes GET request with SSRF validation.
20     *
21     * @param string                $url     Target URL.
22     * @param array<string, string> $headers Request headers.
23     * @param int                   $timeout Max timeout in seconds.
24     * @return array{status: int, body: string}
25     */
26    public function get(string $url, array $headers = [], int $timeout = 3): array;
27
28    /**
29     * Executes POST request with SSRF validation.
30     *
31     * @param string                $url     Target URL.
32     * @param array<string, string> $headers Request headers.
33     * @param string|null           $body    Request payload.
34     * @param int                   $timeout Max timeout in seconds.
35     * @return array{status: int, body: string}
36     */
37    public function post(string $url, array $headers = [], ?string $body = null, int $timeout = 3): array;
38
39    /**
40     * Executes an outbound HTTP request with SSRF validation and strict timeout limits.
41     *
42     * @param string                $url     Target API endpoint.
43     * @param string                $method  HTTP method ('GET', 'POST', etc.).
44     * @param array<string, string> $headers Request headers.
45     * @param string|null           $body    Optional JSON or form payload.
46     * @param int                   $timeout Max request timeout in seconds.
47     * @return array{status: int, body: string} HTTP response status code and body.
48     */
49    public function request(
50        string $url,
51        string $method = 'GET',
52        array $headers = [],
53        ?string $body = null,
54        int $timeout = 3
55    ): array;
56}