PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 2.4.6
Booking for Appointments and Events Calendar – Amelia v2.4.6
2.4.7 2.4.6 2.4.5 2.4.4 2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / vendor / slim / psr7 / src / Message.php
ameliabooking / vendor / slim / psr7 / src Last commit date
Factory 2 months ago Interfaces 2 months ago Cookies.php 2 months ago Environment.php 2 months ago Header.php 2 months ago Headers.php 2 months ago Message.php 2 months ago NonBufferedBody.php 2 months ago Request.php 2 months ago Response.php 2 months ago Stream.php 2 months ago UploadedFile.php 2 months ago Uri.php 2 months ago
Message.php
186 lines
1 <?php
2
3 /**
4 * Slim Framework (https://slimframework.com)
5 *
6 * @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
7 */
8
9 declare(strict_types=1);
10
11 namespace Slim\Psr7;
12
13 use InvalidArgumentException;
14 use AmeliaVendor\Psr\Http\Message\MessageInterface;
15 use AmeliaVendor\Psr\Http\Message\StreamInterface;
16 use Slim\Psr7\Interfaces\HeadersInterface;
17
18 use function array_keys;
19 use function header;
20 use function header_remove;
21 use function implode;
22 use function sprintf;
23
24 abstract class Message implements MessageInterface
25 {
26 protected string $protocolVersion = '1.1';
27
28 protected static array $validProtocolVersions = [
29 '1.0' => true,
30 '1.1' => true,
31 '2.0' => true,
32 '2' => true,
33 ];
34
35 /**
36 * @var HeadersInterface
37 */
38 protected $headers;
39
40 /**
41 * @var StreamInterface
42 */
43 protected $body;
44
45 /**
46 * Disable magic setter to ensure immutability
47 *
48 * @param string $name The property name
49 * @param mixed $value The property value
50 *
51 * @return void
52 */
53 public function __set($name, $value): void
54 {
55 // Do nothing
56 }
57
58 /**
59 * {@inheritdoc}
60 */
61 public function getProtocolVersion(): string
62 {
63 return $this->protocolVersion;
64 }
65
66 /**
67 * @return static
68 * {@inheritdoc}
69 */
70 public function withProtocolVersion($version)
71 {
72 if (!isset(self::$validProtocolVersions[$version])) {
73 throw new InvalidArgumentException(
74 'Invalid HTTP version. Must be one of: '
75 . implode(', ', array_keys(self::$validProtocolVersions))
76 );
77 }
78
79 $clone = clone $this;
80 $clone->protocolVersion = $version;
81
82 return $clone;
83 }
84
85 /**
86 * {@inheritdoc}
87 */
88 public function getHeaders(): array
89 {
90 return $this->headers->getHeaders(true);
91 }
92
93 /**
94 * {@inheritdoc}
95 */
96 public function hasHeader($name): bool
97 {
98 return $this->headers->hasHeader($name);
99 }
100
101 /**
102 * {@inheritdoc}
103 */
104 public function getHeader($name): array
105 {
106 return $this->headers->getHeader($name);
107 }
108
109 /**
110 * {@inheritdoc}
111 */
112 public function getHeaderLine($name): string
113 {
114 $values = $this->headers->getHeader($name);
115 return implode(',', $values);
116 }
117
118 /**
119 * @return static
120 * {@inheritdoc}
121 */
122 public function withHeader($name, $value)
123 {
124 $clone = clone $this;
125 $clone->headers->setHeader($name, $value);
126
127 if ($this instanceof Response && $this->body instanceof NonBufferedBody) {
128 header(sprintf('%s: %s', $name, $clone->getHeaderLine($name)));
129 }
130
131 return $clone;
132 }
133
134 /**
135 * @return static
136 * {@inheritdoc}
137 */
138 public function withAddedHeader($name, $value)
139 {
140 $clone = clone $this;
141 $clone->headers->addHeader($name, $value);
142
143 if ($this instanceof Response && $this->body instanceof NonBufferedBody) {
144 header(sprintf('%s: %s', $name, $clone->getHeaderLine($name)));
145 }
146
147 return $clone;
148 }
149
150 /**
151 * @return static
152 * {@inheritdoc}
153 */
154 public function withoutHeader($name)
155 {
156 $clone = clone $this;
157 $clone->headers->removeHeader($name);
158
159 if ($this instanceof Response && $this->body instanceof NonBufferedBody) {
160 header_remove($name);
161 }
162
163 return $clone;
164 }
165
166 /**
167 * {@inheritdoc}
168 */
169 public function getBody(): StreamInterface
170 {
171 return $this->body;
172 }
173
174 /**
175 * @return static
176 * {@inheritdoc}
177 */
178 public function withBody(StreamInterface $body)
179 {
180 $clone = clone $this;
181 $clone->body = $body;
182
183 return $clone;
184 }
185 }
186