1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* It's free open-source software released under the MIT License. |
5
|
|
|
* |
6
|
|
|
* @author Anatoly Nekhay <[email protected]> |
7
|
|
|
* @copyright Copyright (c) 2018, Anatoly Nekhay |
8
|
|
|
* @license https://github.com/sunrise-php/http-client-curl/blob/master/LICENSE |
9
|
|
|
* @link https://github.com/sunrise-php/http-client-curl |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
declare(strict_types=1); |
13
|
|
|
|
14
|
|
|
namespace Sunrise\Http\Client\Curl; |
15
|
|
|
|
16
|
|
|
use InvalidArgumentException; |
17
|
|
|
use LogicException; |
18
|
|
|
use Psr\Http\Message\MessageInterface; |
19
|
|
|
use Psr\Http\Message\ResponseInterface; |
20
|
|
|
use Psr\Http\Message\StreamInterface; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @since 2.0.0 |
24
|
|
|
*/ |
25
|
|
|
final class MultiResponse implements ResponseInterface |
26
|
|
|
{ |
27
|
|
|
/** |
28
|
|
|
* @var non-empty-array<array-key, ResponseInterface> |
|
|
|
|
29
|
|
|
*/ |
30
|
|
|
private array $responses; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @throws InvalidArgumentException |
34
|
|
|
*/ |
35
|
17 |
|
public function __construct(ResponseInterface ...$responses) |
36
|
|
|
{ |
37
|
17 |
|
if ($responses === []) { |
38
|
1 |
|
throw new InvalidArgumentException('At least one response is expected.'); |
39
|
|
|
} |
40
|
|
|
|
41
|
16 |
|
$this->responses = $responses; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @return non-empty-array<array-key, ResponseInterface> |
|
|
|
|
46
|
|
|
*/ |
47
|
2 |
|
public function getResponses(): array |
48
|
|
|
{ |
49
|
2 |
|
return $this->responses; |
50
|
|
|
} |
51
|
|
|
|
52
|
1 |
|
public function getProtocolVersion(): string |
53
|
|
|
{ |
54
|
1 |
|
throw new LogicException('Not implemented.'); |
55
|
|
|
} |
56
|
|
|
|
57
|
1 |
|
public function withProtocolVersion($version): MessageInterface |
58
|
|
|
{ |
59
|
1 |
|
throw new LogicException('Not implemented.'); |
60
|
|
|
} |
61
|
|
|
|
62
|
1 |
|
public function getHeaders(): array |
63
|
|
|
{ |
64
|
1 |
|
throw new LogicException('Not implemented.'); |
65
|
|
|
} |
66
|
|
|
|
67
|
1 |
|
public function hasHeader($name): bool |
68
|
|
|
{ |
69
|
1 |
|
throw new LogicException('Not implemented.'); |
70
|
|
|
} |
71
|
|
|
|
72
|
1 |
|
public function getHeader($name): array |
73
|
|
|
{ |
74
|
1 |
|
throw new LogicException('Not implemented.'); |
75
|
|
|
} |
76
|
|
|
|
77
|
1 |
|
public function getHeaderLine($name): string |
78
|
|
|
{ |
79
|
1 |
|
throw new LogicException('Not implemented.'); |
80
|
|
|
} |
81
|
|
|
|
82
|
1 |
|
public function withHeader($name, $value): MessageInterface |
83
|
|
|
{ |
84
|
1 |
|
throw new LogicException('Not implemented.'); |
85
|
|
|
} |
86
|
|
|
|
87
|
1 |
|
public function withAddedHeader($name, $value): MessageInterface |
88
|
|
|
{ |
89
|
1 |
|
throw new LogicException('Not implemented.'); |
90
|
|
|
} |
91
|
|
|
|
92
|
1 |
|
public function withoutHeader($name): MessageInterface |
93
|
|
|
{ |
94
|
1 |
|
throw new LogicException('Not implemented.'); |
95
|
|
|
} |
96
|
|
|
|
97
|
1 |
|
public function getBody(): StreamInterface |
98
|
|
|
{ |
99
|
1 |
|
throw new LogicException('Not implemented.'); |
100
|
|
|
} |
101
|
|
|
|
102
|
1 |
|
public function withBody(StreamInterface $body): MessageInterface |
103
|
|
|
{ |
104
|
1 |
|
throw new LogicException('Not implemented.'); |
105
|
|
|
} |
106
|
|
|
|
107
|
1 |
|
public function getStatusCode(): int |
108
|
|
|
{ |
109
|
1 |
|
throw new LogicException('Not implemented.'); |
110
|
|
|
} |
111
|
|
|
|
112
|
1 |
|
public function withStatus($code, $reasonPhrase = ''): ResponseInterface |
113
|
|
|
{ |
114
|
1 |
|
throw new LogicException('Not implemented.'); |
115
|
|
|
} |
116
|
|
|
|
117
|
1 |
|
public function getReasonPhrase(): string |
118
|
|
|
{ |
119
|
1 |
|
throw new LogicException('Not implemented.'); |
120
|
|
|
} |
121
|
|
|
} |
122
|
|
|
|