Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 148 | Zur aktuellen Revision | Details | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
991 lars 3
declare(strict_types=1);
4
 
148 lars 5
namespace Psr\Http\Message;
6
 
7
/**
8
 * Representation of an outgoing, server-side response.
9
 *
10
 * Per the HTTP specification, this interface includes properties for
11
 * each of the following:
12
 *
13
 * - Protocol version
14
 * - Status code and reason phrase
15
 * - Headers
16
 * - Message body
17
 *
18
 * Responses are considered immutable; all methods that might change state MUST
19
 * be implemented such that they retain the internal state of the current
20
 * message and return an instance that contains the changed state.
21
 */
22
interface ResponseInterface extends MessageInterface
23
{
24
    /**
25
     * Gets the response status code.
26
     *
27
     * The status code is a 3-digit integer result code of the server's attempt
28
     * to understand and satisfy the request.
29
     *
30
     * @return int Status code.
31
     */
32
    public function getStatusCode();
33
 
34
    /**
35
     * Return an instance with the specified status code and, optionally, reason phrase.
36
     *
37
     * If no reason phrase is specified, implementations MAY choose to default
38
     * to the RFC 7231 or IANA recommended reason phrase for the response's
39
     * status code.
40
     *
41
     * This method MUST be implemented in such a way as to retain the
42
     * immutability of the message, and MUST return an instance that has the
43
     * updated status and reason phrase.
44
     *
45
     * @link http://tools.ietf.org/html/rfc7231#section-6
46
     * @link http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
47
     * @param int $code The 3-digit integer result code to set.
48
     * @param string $reasonPhrase The reason phrase to use with the
49
     *     provided status code; if none is provided, implementations MAY
50
     *     use the defaults as suggested in the HTTP specification.
51
     * @return static
52
     * @throws \InvalidArgumentException For invalid status code arguments.
53
     */
991 lars 54
    public function withStatus(int $code, string $reasonPhrase = '');
148 lars 55
 
56
    /**
57
     * Gets the response reason phrase associated with the status code.
58
     *
59
     * Because a reason phrase is not a required element in a response
60
     * status line, the reason phrase value MAY be null. Implementations MAY
61
     * choose to return the default RFC 7231 recommended reason phrase (or those
62
     * listed in the IANA HTTP Status Code Registry) for the response's
63
     * status code.
64
     *
65
     * @link http://tools.ietf.org/html/rfc7231#section-6
66
     * @link http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
67
     * @return string Reason phrase; must return an empty string if none present.
68
     */
69
    public function getReasonPhrase();
70
}