Skip to content

Commit

Permalink
[UPDATE] Some minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Neirda24 committed Mar 25, 2024
1 parent 2bcc4d2 commit 0e5caff
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
16 changes: 11 additions & 5 deletions src/Builder/AbstractPdfBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ abstract class AbstractPdfBuilder implements PdfBuilderInterface
*/
protected array $formFields = [];

private string|null $fileName;
private string|null $fileName = null;

private string $headerDisposition = HeaderUtils::DISPOSITION_INLINE;

public function __construct(
protected readonly GotenbergClientInterface $gotenbergClient,
Expand All @@ -26,7 +28,7 @@ public function __construct(
/**
* Compiles the form values into a multipart form data array to send to the HTTP client.
*
* @return array<int, array<string, string>>
* @return list<array<string, string>>
*/
abstract public function getMultipartFormData(): array;

Expand All @@ -40,9 +42,13 @@ abstract protected function getEndpoint(): string;
*/
abstract public function setConfigurations(array $configurations): self;

public function withFileName(string $fileName): static
/**
* @param HeaderUtils::DISPOSITION_* $headerDisposition
*/
public function fileName(string $fileName, string $headerDisposition = HeaderUtils::DISPOSITION_INLINE): static
{
$this->fileName = $fileName;
$this->headerDisposition = $headerDisposition;

return $this;
}
Expand All @@ -53,7 +59,7 @@ public function generate(): PdfResponse

if (null !== $this->fileName) {
$disposition = HeaderUtils::makeDisposition(
HeaderUtils::DISPOSITION_INLINE, # TODO : make dynamic
$this->headerDisposition,
$this->fileName
);

Expand All @@ -66,7 +72,7 @@ public function generate(): PdfResponse
}

/**
* @param string[] $validExtensions
* @param non-empty-list<string> $validExtensions
*/
protected function assertFileExtension(string $path, array $validExtensions): void
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final class Kernel extends BaseKernel implements CompilerPassInterface
{
use MicroKernelTrait;

public function getBuildDir(): string
public function getCacheDir(): string
{
return __DIR__ . '/../var/cache';
}
Expand Down

0 comments on commit 0e5caff

Please sign in to comment.