aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/http/lib/RequestDecorator.php
blob: 0ad24925f4ea9045070210a1af0ae62d88bf40cf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<?php

declare(strict_types=1);

namespace Sabre\HTTP;

/**
 * Request Decorator.
 *
 * This helper class allows you to easily create decorators for the Request
 * object.
 *
 * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
 * @author Evert Pot (http://evertpot.com/)
 * @license http://sabre.io/license/ Modified BSD License
 */
class RequestDecorator implements RequestInterface
{
    use MessageDecoratorTrait;

    /**
     * Constructor.
     */
    public function __construct(RequestInterface $inner)
    {
        $this->inner = $inner;
    }

    /**
     * Returns the current HTTP method.
     */
    public function getMethod(): string
    {
        return $this->inner->getMethod();
    }

    /**
     * Sets the HTTP method.
     */
    public function setMethod(string $method)
    {
        $this->inner->setMethod($method);
    }

    /**
     * Returns the request url.
     */
    public function getUrl(): string
    {
        return $this->inner->getUrl();
    }

    /**
     * Sets the request url.
     */
    public function setUrl(string $url)
    {
        $this->inner->setUrl($url);
    }

    /**
     * Returns the absolute url.
     */
    public function getAbsoluteUrl(): string
    {
        return $this->inner->getAbsoluteUrl();
    }

    /**
     * Sets the absolute url.
     */
    public function setAbsoluteUrl(string $url)
    {
        $this->inner->setAbsoluteUrl($url);
    }

    /**
     * Returns the current base url.
     */
    public function getBaseUrl(): string
    {
        return $this->inner->getBaseUrl();
    }

    /**
     * Sets a base url.
     *
     * This url is used for relative path calculations.
     *
     * The base url should default to /
     */
    public function setBaseUrl(string $url)
    {
        $this->inner->setBaseUrl($url);
    }

    /**
     * Returns the relative path.
     *
     * This is being calculated using the base url. This path will not start
     * with a slash, so it will always return something like
     * 'example/path.html'.
     *
     * If the full path is equal to the base url, this method will return an
     * empty string.
     *
     * This method will also urldecode the path, and if the url was incoded as
     * ISO-8859-1, it will convert it to UTF-8.
     *
     * If the path is outside of the base url, a LogicException will be thrown.
     */
    public function getPath(): string
    {
        return $this->inner->getPath();
    }

    /**
     * Returns the list of query parameters.
     *
     * This is equivalent to PHP's $_GET superglobal.
     */
    public function getQueryParameters(): array
    {
        return $this->inner->getQueryParameters();
    }

    /**
     * Returns the POST data.
     *
     * This is equivalent to PHP's $_POST superglobal.
     */
    public function getPostData(): array
    {
        return $this->inner->getPostData();
    }

    /**
     * Sets the post data.
     *
     * This is equivalent to PHP's $_POST superglobal.
     *
     * This would not have been needed, if POST data was accessible as
     * php://input, but unfortunately we need to special case it.
     */
    public function setPostData(array $postData)
    {
        $this->inner->setPostData($postData);
    }

    /**
     * Returns an item from the _SERVER array.
     *
     * If the value does not exist in the array, null is returned.
     *
     * @return string|null
     */
    public function getRawServerValue(string $valueName)
    {
        return $this->inner->getRawServerValue($valueName);
    }

    /**
     * Sets the _SERVER array.
     */
    public function setRawServerData(array $data)
    {
        $this->inner->setRawServerData($data);
    }

    /**
     * Serializes the request object as a string.
     *
     * This is useful for debugging purposes.
     */
    public function __toString(): string
    {
        return $this->inner->__toString();
    }
}