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