Skip to content

Commit 50c0241

Browse files
committed
Http: Review stream interfaces
- Add `MultipartStreamInterface::getParts()` for completeness - Rename `StreamPartInterface` methods for clarity and consistency: - `getFallbackFilename()` -> `getAsciiFilename()` - `getContent()` -> `getBody()` - Review `HttpMultipartStream` (rename pending) - Do not remain operational after `close()` or `detach()` are called
1 parent 36a7207 commit 50c0241

File tree

7 files changed

+169
-126
lines changed

7 files changed

+169
-126
lines changed

src/Toolkit/Contract/Http/Message/MultipartStreamInterface.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,20 @@
44

55
use Salient\Contract\Http\HasHttpHeader;
66

7+
/**
8+
* @api
9+
*/
710
interface MultipartStreamInterface extends StreamInterface, HasHttpHeader
811
{
912
/**
10-
* Get the stream's encapsulation boundary
13+
* Get an array that contains each of the stream's parts
14+
*
15+
* @return StreamPartInterface[]
16+
*/
17+
public function getParts(): array;
18+
19+
/**
20+
* Get the encapsulation boundary of the stream
1121
*/
1222
public function getBoundary(): string;
1323
}

src/Toolkit/Contract/Http/Message/StreamInterface.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Psr\Http\Message\StreamInterface as PsrStreamInterface;
66
use Stringable;
77

8-
interface StreamInterface extends
9-
PsrStreamInterface,
10-
Stringable {}
8+
/**
9+
* @api
10+
*/
11+
interface StreamInterface extends PsrStreamInterface, Stringable {}

src/Toolkit/Contract/Http/Message/StreamPartInterface.php

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,40 @@
66
use Salient\Contract\Core\Immutable;
77
use Salient\Contract\Http\HasMediaType;
88

9+
/**
10+
* @api
11+
*/
912
interface StreamPartInterface extends Immutable, HasMediaType
1013
{
1114
/**
12-
* Get an instance with the given field name
15+
* Get the field name of the part
1316
*/
14-
public function withName(string $name): StreamPartInterface;
17+
public function getName(): string;
1518

1619
/**
17-
* Get the field name of the part
20+
* Get an instance with the given field name
21+
*
22+
* @return static
1823
*/
19-
public function getName(): string;
24+
public function withName(string $name): StreamPartInterface;
2025

2126
/**
2227
* Get the filename of the part
2328
*/
2429
public function getFilename(): ?string;
2530

2631
/**
27-
* Get the ASCII fallback filename of the part
32+
* Get the ASCII filename of the part
2833
*/
29-
public function getFallbackFilename(): ?string;
34+
public function getAsciiFilename(): ?string;
3035

3136
/**
3237
* Get the media type of the part
3338
*/
3439
public function getMediaType(): ?string;
3540

3641
/**
37-
* Get the content of the part
42+
* Get the body of the part
3843
*/
39-
public function getContent(): PsrStreamInterface;
44+
public function getBody(): PsrStreamInterface;
4045
}

0 commit comments

Comments
 (0)