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 * @link      https://github.com/php-fast-forward/http-factory
12 * @copyright Copyright (c) 2025 Felipe SayĆ£o Lobato Abreu <github@mentordosnerds.com>
13 * @license   https://opensource.org/licenses/MIT MIT License
14 */
15
16namespace FastForward\Http\Message\Factory;
17
18use FastForward\Http\Message\PayloadStreamInterface;
19use Psr\Http\Message\StreamFactoryInterface as PsrStreamFactoryInterface;
20
21/**
22 * Interface StreamFactoryInterface.
23 *
24 * Extends the PSR-17 StreamFactoryInterface with additional functionality for creating streams from payloads.
25 * Implementations of this interface MUST be capable of generating standard PSR-7 streams as well as payload-aware streams.
26 *
27 * @package FastForward\Http\Message\Factory
28 */
29interface StreamFactoryInterface extends PsrStreamFactoryInterface
30{
31    /**
32     * Creates a new stream containing the JSON-encoded representation of the provided payload.
33     *
34     * The returned stream MUST implement PayloadStreamInterface and MUST be readable and seekable.
35     * The payload MUST be JSON-encodable and MUST NOT contain resource types.
36     *
37     * @param array $payload the payload to encode and wrap in the stream
38     *
39     * @return PayloadStreamInterface the generated stream containing the payload
40     */
41    public function createStreamFromPayload(array $payload): PayloadStreamInterface;
42}