Skip to content

Commit 3046fa3

Browse files
committed
Provide Content-Disposition in Attachment
1 parent 777ff6d commit 3046fa3

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

src/Attachment.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public function __construct(
1616
protected ?string $filename,
1717
protected ?string $contentId,
1818
protected string $contentType,
19+
protected ?string $contentDisposition,
1920
protected StreamInterface $contentStream,
2021
) {}
2122

@@ -43,6 +44,14 @@ public function contentType(): string
4344
return $this->contentType;
4445
}
4546

47+
/**
48+
* Get the attachment's content disposition.
49+
*/
50+
public function contentDisposition(): string
51+
{
52+
return $this->contentDisposition;
53+
}
54+
4655
/**
4756
* Get the attachment's contents.
4857
*/

src/HasParsedMessage.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ public function attachments(): array
136136
$part->getFilename(),
137137
$part->getContentId(),
138138
$part->getContentType(),
139+
$part->getContentDisposition(),
139140
$part->getBinaryContentStream() ?? Utils::streamFor(''),
140141
);
141142
}

tests/Unit/AttachmentTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
test('extension', function () {
77
$stream = new LazyOpenStream('test.jpg', 'r');
88

9-
$ext = (new Attachment('test.jpg', null, 'image/jpeg', $stream))->extension();
9+
$ext = (new Attachment('test.jpg', null, 'image/jpeg', 'attachment', $stream))->extension();
1010

1111
expect($ext)->toBe('jpg');
1212
});
1313

1414
test('extension with content type', function () {
1515
$stream = new LazyOpenStream('test', 'r');
1616

17-
$ext = (new Attachment('test', null, 'image/jpeg', $stream))->extension();
17+
$ext = (new Attachment('test', null, 'image/jpeg', 'attachment', $stream))->extension();
1818

1919
expect($ext)->toBe('jpg');
2020
});

0 commit comments

Comments
 (0)