1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Yiisoft\Yii\Runner\Http; |
6
|
|
|
|
7
|
|
|
use Psr\Http\Message\ResponseInterface; |
8
|
|
|
use Psr\Http\Message\StreamInterface; |
9
|
|
|
use RuntimeException; |
10
|
|
|
use Yiisoft\Http\Status; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @internal |
14
|
|
|
*/ |
15
|
|
|
final class BadRequestResponse implements ResponseInterface |
16
|
|
|
{ |
17
|
14 |
|
public function __construct( |
18
|
|
|
private string $reasonPhrase, |
19
|
|
|
) { |
20
|
14 |
|
} |
21
|
|
|
|
22
|
2 |
|
public function getProtocolVersion(): string |
23
|
|
|
{ |
24
|
2 |
|
return '1.1'; |
25
|
|
|
} |
26
|
|
|
|
27
|
1 |
|
public function withProtocolVersion(string $version): void |
28
|
|
|
{ |
29
|
1 |
|
throw new RuntimeException('Method "withProtocolVersion" is not supported.'); |
30
|
|
|
} |
31
|
|
|
|
32
|
2 |
|
public function getHeaders(): array |
33
|
|
|
{ |
34
|
2 |
|
return []; |
35
|
|
|
} |
36
|
|
|
|
37
|
1 |
|
public function hasHeader(string $name): bool |
38
|
|
|
{ |
39
|
1 |
|
return false; |
40
|
|
|
} |
41
|
|
|
|
42
|
1 |
|
public function getHeader(string $name): array |
43
|
|
|
{ |
44
|
1 |
|
return []; |
45
|
|
|
} |
46
|
|
|
|
47
|
1 |
|
public function getHeaderLine(string $name): string |
48
|
|
|
{ |
49
|
1 |
|
return ''; |
50
|
|
|
} |
51
|
|
|
|
52
|
1 |
|
public function withHeader(string $name, $value): self |
53
|
|
|
{ |
54
|
1 |
|
throw new RuntimeException('Method "withHeader" is not supported.'); |
55
|
|
|
} |
56
|
|
|
|
57
|
1 |
|
public function withAddedHeader(string $name, $value): self |
58
|
|
|
{ |
59
|
1 |
|
throw new RuntimeException('Method "withAddedHeader" is not supported.'); |
60
|
|
|
} |
61
|
|
|
|
62
|
2 |
|
public function withoutHeader(string $name): self |
63
|
|
|
{ |
64
|
2 |
|
return $this; |
65
|
|
|
} |
66
|
|
|
|
67
|
9 |
|
public function getBody(): StreamInterface |
68
|
|
|
{ |
69
|
9 |
|
return new class() implements StreamInterface { |
70
|
|
|
public function __toString(): string |
71
|
|
|
{ |
72
|
1 |
|
throw new RuntimeException('Method "__toString" is not supported.'); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public function close(): void |
76
|
|
|
{ |
77
|
1 |
|
} |
78
|
|
|
|
79
|
|
|
public function detach() |
80
|
|
|
{ |
81
|
1 |
|
return null; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
public function getSize(): ?int |
85
|
|
|
{ |
86
|
1 |
|
return null; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
public function tell(): int |
90
|
|
|
{ |
91
|
1 |
|
throw new RuntimeException('Method "tell" is not supported.'); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
public function eof(): bool |
95
|
|
|
{ |
96
|
1 |
|
return false; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
public function isSeekable(): bool |
100
|
|
|
{ |
101
|
1 |
|
return false; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
public function seek(int $offset, int $whence = SEEK_SET): void |
105
|
|
|
{ |
106
|
1 |
|
throw new RuntimeException('Method "seek" is not supported.'); |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
public function rewind(): void |
110
|
|
|
{ |
111
|
1 |
|
throw new RuntimeException('Method "rewind" is not supported.'); |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
public function isWritable(): bool |
115
|
|
|
{ |
116
|
1 |
|
return false; |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
public function write(string $string): void |
120
|
|
|
{ |
121
|
1 |
|
throw new RuntimeException('Method "write" is not supported.'); |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
public function isReadable(): bool |
125
|
|
|
{ |
126
|
2 |
|
return false; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
public function read(int $length): void |
130
|
|
|
{ |
131
|
1 |
|
throw new RuntimeException('Method "read" is not supported.'); |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
public function getContents(): void |
135
|
|
|
{ |
136
|
1 |
|
throw new RuntimeException('Method "getContents" is not supported.'); |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
public function getMetadata(?string $key = null): mixed |
140
|
|
|
{ |
141
|
1 |
|
return null; |
142
|
|
|
} |
143
|
9 |
|
}; |
144
|
|
|
} |
145
|
|
|
|
146
|
1 |
|
public function withBody(StreamInterface $body): self |
147
|
|
|
{ |
148
|
1 |
|
throw new RuntimeException('Method "withBody" is not supported.'); |
149
|
|
|
} |
150
|
|
|
|
151
|
2 |
|
public function getStatusCode(): int |
152
|
|
|
{ |
153
|
2 |
|
return Status::BAD_REQUEST; |
154
|
|
|
} |
155
|
|
|
|
156
|
1 |
|
public function withStatus(int $code, string $reasonPhrase = ''): self |
157
|
|
|
{ |
158
|
1 |
|
throw new RuntimeException('Method "withStatus" is not supported.'); |
159
|
|
|
} |
160
|
|
|
|
161
|
2 |
|
public function getReasonPhrase(): string |
162
|
|
|
{ |
163
|
2 |
|
return $this->reasonPhrase; |
164
|
|
|
} |
165
|
|
|
} |
166
|
|
|
|