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
2declare(strict_types=1);
3/**
4 * Pop PHP Framework (https://www.popphp.org/)
5 *
6 * @link       https://github.com/popphp/popphp-framework
7 * @author     Nick Sagona, III <nick@popphp.org>
8 * @copyright  Copyright (c) 2009-2026 Nick Sagona, III
9 * @license    https://www.popphp.org/license     New BSD License
10 */
11
12/**
13 * @namespace
14 */
15namespace Pop\Http;
16
17use Pop\Mime\Part\Header;
18use Pop\Http\Body;
19
20/**
21 * HTTP request/response interface
22 *
23 * @category   Pop
24 * @package    Pop\Http
25 * @author     Nick Sagona, III <nick@popphp.org>
26 * @copyright  Copyright (c) 2009-2026 Nick Sagona, III
27 * @license    https://www.popphp.org/license     New BSD License
28 * @version    6.0.0
29 */
30interface RequestResponseInterface
31{
32
33    /**
34     * Set all headers (clear out any existing headers)
35     *
36     * @param  array $headers
37     * @return RequestResponseInterface
38     */
39    public function setHeaders(array $headers): RequestResponseInterface;
40
41    /**
42     * Set a header
43     *
44     * @param  Header|string|int $header
45     * @param  ?string           $value
46     * @return RequestResponseInterface
47     */
48    public function addHeader(Header|string|int $header, ?string $value = null): RequestResponseInterface;
49
50    /**
51     * Add all headers
52     *
53     * @param  array $headers
54     * @return RequestResponseInterface
55     */
56    public function addHeaders(array $headers): RequestResponseInterface;
57
58    /**
59     * Get a header
60     *
61     * @param  string $name
62     * @return mixed
63     */
64    public function getHeader(string $name): mixed;
65
66    /**
67     * Get a header
68     *
69     * @param  string $name
70     * @return mixed
71     */
72    public function getHeaderAsString(string $name): mixed;
73
74    /**
75     * Get header value
76     *
77     * @param  string $name
78     * @param  int    $i
79     * @return mixed
80     */
81    public function getHeaderValue(string $name, int $i = 0): mixed;
82
83    /**
84     * Get header value as string
85     *
86     * @param  string $name
87     * @param  int    $i
88     * @return string|null
89     */
90    public function getHeaderValueAsString(string $name, int $i = 0): string|null;
91
92    /**
93     * Get all headers
94     *
95     * @return array
96     */
97    public function getHeaders(): array;
98
99    /**
100     * Get all header values as associative array
101     *
102     * @return array
103     */
104    public function getHeadersAsArray(): array;
105
106    /**
107     * Get all header values formatted string
108     *
109     * @param  ?string $status
110     * @param  string  $eol
111     * @return string
112     */
113    public function getHeadersAsString(?string $status = null, string $eol = "\r\n"): string;
114
115    /**
116     * Determine if there are headers
117     *
118     * @return bool
119     */
120    public function hasHeaders(): bool;
121
122    /**
123     * Has a header
124     *
125     * @param  string $name
126     * @return bool
127     */
128    public function hasHeader(string $name): bool;
129
130    /**
131     * Remove a header
132     *
133     * @param  string $name
134     * @return RequestResponseInterface
135     */
136    public function removeHeader(string $name): RequestResponseInterface;
137
138    /**
139     * Remove all headers
140     *
141     * @return RequestResponseInterface
142     */
143    public function removeHeaders(): RequestResponseInterface;
144
145    /**
146     * Set the body
147     *
148     * @param  string|Body $body
149     * @return RequestResponseInterface
150     */
151    public function setBody(string|Body $body): RequestResponseInterface;
152
153    /**
154     * Get the body
155     *
156     * @return Body
157     */
158    public function getBody(): Body;
159
160    /**
161     * Get body content
162     *
163     * @return mixed
164     */
165    public function getBodyContent(): mixed;
166
167    /**
168     * Get body content length
169     *
170     * @param  bool $mb
171     * @return int
172     */
173    public function getBodyContentLength(bool $mb = false): int;
174
175    /**
176     * Has a body
177     *
178     * @return bool
179     */
180    public function hasBody(): bool;
181
182    /**
183     * Has body content
184     *
185     * @return bool
186     */
187    public function hasBodyContent(): bool;
188
189    /**
190     * Decode the body content
191     *
192     * @param  ?string $body
193     * @return Body
194     */
195    public function decodeBodyContent(?string $body = null): Body;
196
197    /**
198     * Remove the body
199     *
200     * @return RequestResponseInterface
201     */
202    public function removeBody(): RequestResponseInterface;
203
204}