Skip to content

Commit

Permalink
remove redundant check in Response
Browse files Browse the repository at this point in the history
  • Loading branch information
garak authored and endelwar committed Nov 25, 2024
1 parent 2ec428d commit 36b16cf
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 10 deletions.
9 changes: 0 additions & 9 deletions src/WeasyPrint/Response/WeasyPrintResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Pontedilana\WeasyprintBundle\WeasyPrint\Response;

use Symfony\Component\HttpFoundation\Response as Base;
use Symfony\Component\HttpFoundation\ResponseHeaderBag;

class WeasyPrintResponse extends Base
{
Expand All @@ -18,14 +17,6 @@ public function __construct(
int $status = 200,
array $headers = []
) {
$contentDispositionDirectives = [
ResponseHeaderBag::DISPOSITION_INLINE,
ResponseHeaderBag::DISPOSITION_ATTACHMENT,
];
if (!\in_array($contentDisposition, $contentDispositionDirectives, true)) {
throw new \InvalidArgumentException(\sprintf('Expected one of the following directives: "%s", but "%s" given.', implode('", "', $contentDispositionDirectives), $contentDisposition));
}

parent::__construct($content, $status, $headers);
$this->headers->add(['Content-Type' => $contentType]);
$this->headers->add(['Content-Disposition' => $this->headers->makeDisposition($contentDisposition, $fileName)]);
Expand Down
2 changes: 1 addition & 1 deletion tests/WeasyPrint/Response/WeasyPrintResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public function testExceptionMessage(): void
try {
new WeasyPrintResponse('', 'test.pdf', 'application/pdf', 'foo');
} catch (\InvalidArgumentException $e) {
$this->assertSame('Expected one of the following directives: "inline", "attachment", but "foo" given.', $e->getMessage());
$this->assertSame('The disposition must be either "attachment" or "inline".', $e->getMessage());
}
}
}

0 comments on commit 36b16cf

Please sign in to comment.