Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
n/a
0 / 0
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2
3declare(strict_types=1);
4
5/**
6 * This file is part of php-fast-forward/http-factory.
7 *
8 * This source file is subject to the license bundled
9 * with this source code in the file LICENSE.
10 *
11 * @copyright Copyright (c) 2025-2026 Felipe SayĆ£o Lobato Abreu <github@mentordosnerds.com>
12 * @license   https://opensource.org/licenses/MIT MIT License
13 *
14 * @see       https://github.com/php-fast-forward/http-factory
15 * @see       https://github.com/php-fast-forward
16 * @see       https://datatracker.ietf.org/doc/html/rfc2119
17 */
18
19namespace FastForward\Http\Message\Factory;
20
21use FastForward\Http\Message\PayloadStreamInterface;
22use Psr\Http\Message\StreamFactoryInterface as PsrStreamFactoryInterface;
23
24/**
25 * Interface StreamFactoryInterface.
26 *
27 * Extends the PSR-17 StreamFactoryInterface with additional functionality for creating streams from payloads.
28 * Implementations of this interface MUST be capable of generating standard PSR-7 streams as well as payload-aware streams.
29 */
30interface StreamFactoryInterface extends PsrStreamFactoryInterface
31{
32    /**
33     * Creates a new stream containing the JSON-encoded representation of the provided payload.
34     *
35     * The returned stream MUST implement PayloadStreamInterface and MUST be readable and seekable.
36     * The payload MUST be JSON-encodable and MUST NOT contain resource types.
37     *
38     * @param array $payload the payload to encode and wrap in the stream
39     *
40     * @return PayloadStreamInterface the generated stream containing the payload
41     */
42    public function createStreamFromPayload(array $payload): PayloadStreamInterface;
43}