Skip to content

Commit

Permalink
Rename PrintOptions to DisplayOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
sprain committed Nov 7, 2024
1 parent f8df108 commit a95172d
Show file tree
Hide file tree
Showing 14 changed files with 62 additions and 62 deletions.
4 changes: 2 additions & 2 deletions example/FpdfOutput/fpdf-example.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php declare(strict_types=1);

use Sprain\SwissQrBill as QrBill;
use Sprain\SwissQrBill\PaymentPart\Output\PrintOptions;
use Sprain\SwissQrBill\PaymentPart\Output\DisplayOptions;

require __DIR__ . '/../../vendor/autoload.php';

Expand All @@ -28,7 +28,7 @@
$output = new QrBill\PaymentPart\Output\FpdfOutput\FpdfOutput($qrBill, 'en', $fpdf);

// 4. Optional, set layout options
$printOptions = new PrintOptions();
$printOptions = new DisplayOptions();
$printOptions
->setPrintable(false) // true to remove lines for printing on a perforated stationery
->setDisplayTextDownArrows(false) // true to show arrows next to separation text, if shown
Expand Down
4 changes: 2 additions & 2 deletions example/HtmlOutput/html-example.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php declare(strict_types=1);

use Sprain\SwissQrBill as QrBill;
use Sprain\SwissQrBill\PaymentPart\Output\PrintOptions;
use Sprain\SwissQrBill\PaymentPart\Output\DisplayOptions;

require __DIR__ . '/../../vendor/autoload.php';

Expand All @@ -12,7 +12,7 @@
$output = new QrBill\PaymentPart\Output\HtmlOutput\HtmlOutput($qrBill, 'en');

// 3. Optional, set layout options
$printOptions = new PrintOptions();
$printOptions = new DisplayOptions();
$printOptions
->setPrintable(false) // true to remove lines for printing on a perforated stationery
->setDisplayTextDownArrows(false) // true to show arrows next to separation text, if shown
Expand Down
4 changes: 2 additions & 2 deletions example/TcPdfOutput/tcpdf-example.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php declare(strict_types=1);

use Sprain\SwissQrBill as QrBill;
use Sprain\SwissQrBill\PaymentPart\Output\PrintOptions;
use Sprain\SwissQrBill\PaymentPart\Output\DisplayOptions;

require __DIR__ . '/../../vendor/autoload.php';

Expand All @@ -19,7 +19,7 @@
$output = new QrBill\PaymentPart\Output\TcPdfOutput\TcPdfOutput($qrBill, 'en', $tcPdf);

// 4. Optional, set layout options
$printOptions = new PrintOptions();
$printOptions = new DisplayOptions();
$printOptions
->setPrintable(false) // true to remove lines for printing on a perforated stationery
->setDisplayTextDownArrows(false) // true to show arrows next to separation text, if shown
Expand Down
22 changes: 11 additions & 11 deletions src/PaymentPart/Output/AbstractOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ abstract class AbstractOutput implements OutputInterface
{
protected QrBill $qrBill;
protected string $language;
protected PrintOptions $printOptions;
protected DisplayOptions $displayOptions;
protected string $qrCodeImageFormat;

public function __construct(QrBill $qrBill, string $language)
{
$this->qrBill = $qrBill;
$this->language = $language;
$this->printOptions = new PrintOptions();
$this->displayOptions = new DisplayOptions();
$this->qrCodeImageFormat = QrCode::FILE_FORMAT_SVG;
}

Expand All @@ -36,35 +36,35 @@ public function getLanguage(): ?string
}

/**
* @deprecated Will be removed in next major release. Use setPrintOptions() instead.
* @deprecated Will be removed in next major release. Use setDisplayOptions() instead.
*/
public function setPrintable(bool $printable): static
{
$this->printOptions->setPrintable($printable);
$this->displayOptions->setPrintable($printable);

return $this;
}

/**
* @deprecated Will be removed in next major release. Use getPrintOptions() instead.
* @deprecated Will be removed in next major release. Use getDisplayOptions() instead.
*/
public function isPrintable(): bool
{
return $this->printOptions->isPrintable();
return $this->displayOptions->isPrintable();
}

public function setPrintOptions(PrintOptions $printOptions): static
public function setDisplayOptions(DisplayOptions $displayOptions): static
{
$this->printOptions = $printOptions;
$this->displayOptions = $displayOptions;

return $this;
}

public function getPrintOptions(): PrintOptions
public function getDisplayOptions(): DisplayOptions
{
$this->printOptions->consolidate();
$this->displayOptions->consolidate();

return $this->printOptions;
return $this->displayOptions;
}

public function setQrCodeImageFormat(string $fileExtension): static
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ final class LineStyle
public const NONE = 'NONE';
}

final class PrintOptions
final class DisplayOptions
{
private bool $isPrintable = false;
private bool $displayScissors = false;
Expand Down
2 changes: 1 addition & 1 deletion src/PaymentPart/Output/FpdfOutput/FpdfOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ private function addFurtherInformationContent(): void

private function addSeparatorContentIfNotPrintable(): void
{
$layout = $this->getPrintOptions();
$layout = $this->getDisplayOptions();
if ($layout->isPrintable()) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/PaymentPart/Output/HtmlOutput/HtmlOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ private function addFurtherInformationContent(string $paymentPart): string

private function hideSeparatorContentIfPrintable(string $paymentPart): string
{
$layout = $this->getPrintOptions();
$layout = $this->getDisplayOptions();
$printableStyles = '';
if ($layout->isPrintable()) {
// draw nothing
Expand Down
4 changes: 2 additions & 2 deletions src/PaymentPart/Output/OutputInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ public function getLanguage(): ?string;

public function getPaymentPart(): ?string;

public function setPrintOptions(PrintOptions $printOptions): static;
public function setDisplayOptions(DisplayOptions $displayOptions): static;

public function getPrintOptions(): PrintOptions;
public function getDisplayOptions(): DisplayOptions;

public function setQrCodeImageFormat(string $imageFormat): static;

Expand Down
2 changes: 1 addition & 1 deletion src/PaymentPart/Output/TcPdfOutput/TcPdfOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ private function addFurtherInformationContent(): void

private function addSeparatorContentIfNotPrintable(): void
{
$layout = $this->getPrintOptions();
$layout = $this->getDisplayOptions();
if ($layout->isPrintable()) {
return;
}
Expand Down
18 changes: 9 additions & 9 deletions tests/PaymentPart/Output/FpdfOutput/FpdfOutputTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Sprain\SwissQrBill\Exception\InvalidFpdfImageFormat;
use Sprain\SwissQrBill\PaymentPart\Output\FpdfOutput\FpdfOutput;
use Sprain\SwissQrBill\PaymentPart\Output\FpdfOutput\UnsupportedEnvironmentException;
use Sprain\SwissQrBill\PaymentPart\Output\PrintOptions;
use Sprain\SwissQrBill\PaymentPart\Output\DisplayOptions;
use Sprain\SwissQrBill\PaymentPart\Output\VerticalSeparatorSymbolPosition;
use Sprain\SwissQrBill\QrBill;
use Sprain\SwissQrBill\QrCode\QrCode;
Expand All @@ -27,27 +27,27 @@ public function testValidQrBills(string $name, QrBill $qrBill): void
{
$variations = [
[
'layout' => (new PrintOptions())->setPrintable(false),
'layout' => (new DisplayOptions())->setPrintable(false),
'format' => QrCode::FILE_FORMAT_PNG,
'file' => dirname(dirname(dirname(__DIR__))) . '/TestData/FpdfOutput/' . $name . '.pdf'
],
[
'layout' => (new PrintOptions())->setPrintable(true),
'layout' => (new DisplayOptions())->setPrintable(true),
'format' => QrCode::FILE_FORMAT_PNG,
'file' => dirname(dirname(dirname(__DIR__))) . '/TestData/FpdfOutput/' . $name . '.print.pdf'
],
[
'layout' => (new PrintOptions())->setPrintable(false)->setDisplayScissors(true),
'layout' => (new DisplayOptions())->setPrintable(false)->setDisplayScissors(true),
'format' => QrCode::FILE_FORMAT_PNG,
'file' => dirname(dirname(dirname(__DIR__))) . '/TestData/FpdfOutput/' . $name . '.scissors.pdf'
],
[
'layout' => (new PrintOptions())->setPrintable(false)->setDisplayScissors(true)->setPositionScissorsAtBottom(true),
'layout' => (new DisplayOptions())->setPrintable(false)->setDisplayScissors(true)->setPositionScissorsAtBottom(true),
'format' => QrCode::FILE_FORMAT_PNG,
'file' => __DIR__ . '/../../../TestData/FpdfOutput/' . $name . '.svg.scissorsdown.pdf'
],
[
'layout' => (new PrintOptions())->setPrintable(false)->setDisplayTextDownArrows(true),
'layout' => (new DisplayOptions())->setPrintable(false)->setDisplayTextDownArrows(true),
'format' => QrCode::FILE_FORMAT_PNG,
'file' => __DIR__ . '/../../../TestData/FpdfOutput/' . $name . '.svg.textarrows.pdf'
]
Expand All @@ -61,7 +61,7 @@ public function testValidQrBills(string $name, QrBill $qrBill): void

$output = new FpdfOutput($qrBill, 'en', $fpdf);
$output
->setPrintOptions($variation['layout'])
->setDisplayOptions($variation['layout'])
->setQrCodeImageFormat($variation['format'])
->getPaymentPart();

Expand Down Expand Up @@ -93,7 +93,7 @@ public function testItThrowsMissingTraitException(): void

$output = new FpdfOutput($qrBill, 'en', $fpdf);
$output
->setPrintOptions((new PrintOptions())->setPrintable(false)->setDisplayScissors(true))
->setDisplayOptions((new DisplayOptions())->setPrintable(false)->setDisplayScissors(true))
->setQrCodeImageFormat(QrCode::FILE_FORMAT_PNG)
->getPaymentPart();
}
Expand All @@ -116,7 +116,7 @@ public function testUtf8SpecialChars(): void

$output = new FpdfOutput($qrBill, 'en', $fpdf);
$output
->setPrintOptions((new PrintOptions())->setPrintable(true))
->setDisplayOptions((new DisplayOptions())->setPrintable(true))
->setQrCodeImageFormat(QrCode::FILE_FORMAT_PNG)
->getPaymentPart();

Expand Down
16 changes: 8 additions & 8 deletions tests/PaymentPart/Output/FpdfOutput/FpdiOutputTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use setasign\Fpdi\Fpdi;
use Sprain\SwissQrBill\Exception\InvalidFpdfImageFormat;
use Sprain\SwissQrBill\PaymentPart\Output\FpdfOutput\FpdfOutput;
use Sprain\SwissQrBill\PaymentPart\Output\PrintOptions;
use Sprain\SwissQrBill\PaymentPart\Output\DisplayOptions;
use Sprain\SwissQrBill\PaymentPart\Output\VerticalSeparatorSymbolPosition;
use Sprain\SwissQrBill\QrBill;
use Sprain\SwissQrBill\QrCode\QrCode;
Expand All @@ -26,27 +26,27 @@ public function testValidQrBills(string $name, QrBill $qrBill): void
{
$variations = [
[
'layout' => (new PrintOptions())->setPrintable(false),
'layout' => (new DisplayOptions())->setPrintable(false),
'format' => QrCode::FILE_FORMAT_PNG,
'file' => dirname(dirname(dirname(__DIR__))) . '/TestData/FpdfOutput/' . $name . '.pdf'
],
[
'layout' => (new PrintOptions())->setPrintable(true),
'layout' => (new DisplayOptions())->setPrintable(true),
'format' => QrCode::FILE_FORMAT_PNG,
'file' => dirname(dirname(dirname(__DIR__))) . '/TestData/FpdfOutput/' . $name . '.print.pdf'
],
[
'layout' => (new PrintOptions())->setPrintable(false)->setDisplayScissors(true),
'layout' => (new DisplayOptions())->setPrintable(false)->setDisplayScissors(true),
'format' => QrCode::FILE_FORMAT_PNG,
'file' => dirname(dirname(dirname(__DIR__))) . '/TestData/FpdfOutput/' . $name . '.scissors.pdf'
],
[
'layout' => (new PrintOptions())->setPrintable(false)->setDisplayScissors(true)->setPositionScissorsAtBottom(true),
'layout' => (new DisplayOptions())->setPrintable(false)->setDisplayScissors(true)->setPositionScissorsAtBottom(true),
'format' => QrCode::FILE_FORMAT_PNG,
'file' => __DIR__ . '/../../../TestData/FpdfOutput/' . $name . '.svg.scissorsdown.pdf'
],
[
'layout' => (new PrintOptions())->setPrintable(false)->setDisplayTextDownArrows(true),
'layout' => (new DisplayOptions())->setPrintable(false)->setDisplayTextDownArrows(true),
'format' => QrCode::FILE_FORMAT_PNG,
'file' => __DIR__ . '/../../../TestData/FpdfOutput/' . $name . '.svg.textarrows.pdf'
]
Expand All @@ -60,7 +60,7 @@ public function testValidQrBills(string $name, QrBill $qrBill): void

$output = new FpdfOutput($qrBill, 'en', $fpdf);
$output
->setPrintOptions($variation['layout'])
->setDisplayOptions($variation['layout'])
->setQrCodeImageFormat($variation['format'])
->getPaymentPart();

Expand Down Expand Up @@ -92,7 +92,7 @@ public function testItThrowsMissingTraitException(): void

$output = new FpdfOutput($qrBill, 'en', $fpdf);
$output
->setPrintOptions((new PrintOptions())->setPrintable(false)->setDisplayScissors(true))
->setDisplayOptions((new DisplayOptions())->setPrintable(false)->setDisplayScissors(true))
->setQrCodeImageFormat(QrCode::FILE_FORMAT_PNG)
->getPaymentPart();
}
Expand Down
14 changes: 7 additions & 7 deletions tests/PaymentPart/Output/HtmlOutput/HtmlOutputTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use PHPUnit\Framework\TestCase;
use Sprain\SwissQrBill\PaymentPart\Output\HtmlOutput\HtmlOutput;
use Sprain\SwissQrBill\PaymentPart\Output\PrintOptions;
use Sprain\SwissQrBill\PaymentPart\Output\DisplayOptions;
use Sprain\SwissQrBill\PaymentPart\Output\VerticalSeparatorSymbolPosition;
use Sprain\SwissQrBill\QrBill;
use Sprain\SwissQrBill\QrCode\QrCode;
Expand All @@ -23,27 +23,27 @@ public function testValidQrBills(string $name, QrBill $qrBill)
{
$variations = [
[
'layout' => (new PrintOptions())->setPrintable(false),
'layout' => (new DisplayOptions())->setPrintable(false),
'format' => QrCode::FILE_FORMAT_SVG,
'file' => __DIR__ . '/../../../TestData/HtmlOutput/' . $name . $this->getCompact() . '.svg.html'
],
[
'layout' => (new PrintOptions())->setPrintable(true),
'layout' => (new DisplayOptions())->setPrintable(true),
'format' => QrCode::FILE_FORMAT_SVG,
'file' => __DIR__ . '/../../../TestData/HtmlOutput/' . $name . $this->getCompact() . '.svg.print.html'
],
[
'layout' => (new PrintOptions())->setPrintable(false)->setDisplayScissors(true),
'layout' => (new DisplayOptions())->setPrintable(false)->setDisplayScissors(true),
'format' => QrCode::FILE_FORMAT_SVG,
'file' => __DIR__ . '/../../../TestData/HtmlOutput/' . $name . $this->getCompact() . '.svg.scissors.html'
],
[
'layout' => (new PrintOptions())->setPrintable(false)->setDisplayScissors(true)->setPositionScissorsAtBottom(true),
'layout' => (new DisplayOptions())->setPrintable(false)->setDisplayScissors(true)->setPositionScissorsAtBottom(true),
'format' => QrCode::FILE_FORMAT_SVG,
'file' => __DIR__ . '/../../../TestData/HtmlOutput/' . $name . '.svg.scissorsdown.html'
],
[
'layout' => (new PrintOptions())->setPrintable(false)->setDisplayTextDownArrows(true),
'layout' => (new DisplayOptions())->setPrintable(false)->setDisplayTextDownArrows(true),
'format' => QrCode::FILE_FORMAT_SVG,
'file' => __DIR__ . '/../../../TestData/HtmlOutput/' . $name . '.svg.textarrows.html'
],
Expand All @@ -66,7 +66,7 @@ public function testValidQrBills(string $name, QrBill $qrBill)

$htmlOutput = (new HtmlOutput($qrBill, 'en'));
$output = $htmlOutput
->setPrintOptions($variation['layout'])
->setDisplayOptions($variation['layout'])
->setQrCodeImageFormat($variation['format'])
->getPaymentPart();

Expand Down
14 changes: 7 additions & 7 deletions tests/PaymentPart/Output/TcPdfOutput/FpdiOutputTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use PHPUnit\Framework\TestCase;
use setasign\Fpdi\Tcpdf\Fpdi;
use Sprain\SwissQrBill\PaymentPart\Output\PrintOptions;
use Sprain\SwissQrBill\PaymentPart\Output\DisplayOptions;
use Sprain\SwissQrBill\PaymentPart\Output\VerticalSeparatorSymbolPosition;
use Sprain\SwissQrBill\PaymentPart\Output\TcPdfOutput\TcPdfOutput;
use Sprain\SwissQrBill\QrBill;
Expand All @@ -22,27 +22,27 @@ public function testValidQrBills(string $name, QrBill $qrBill): void
{
$variations = [
[
'layout' => (new PrintOptions())->setPrintable(false),
'layout' => (new DisplayOptions())->setPrintable(false),
'format' => QrCode::FILE_FORMAT_SVG,
'file' => __DIR__ . '/../../../TestData/TcPdfOutput/' . $name . '.svg.pdf'
],
[
'layout' => (new PrintOptions())->setPrintable(true),
'layout' => (new DisplayOptions())->setPrintable(true),
'format' => QrCode::FILE_FORMAT_SVG,
'file' => __DIR__ . '/../../../TestData/TcPdfOutput/' . $name . '.svg.print.pdf'
],
[
'layout' => (new PrintOptions())->setPrintable(false)->setDisplayScissors(true),
'layout' => (new DisplayOptions())->setPrintable(false)->setDisplayScissors(true),
'format' => QrCode::FILE_FORMAT_SVG,
'file' => __DIR__ . '/../../../TestData/TcPdfOutput/' . $name . '.svg.scissors.pdf'
],
[
'layout' => (new PrintOptions())->setPrintable(false)->setDisplayScissors(true)->setPositionScissorsAtBottom(true),
'layout' => (new DisplayOptions())->setPrintable(false)->setDisplayScissors(true)->setPositionScissorsAtBottom(true),
'format' => QrCode::FILE_FORMAT_SVG,
'file' => __DIR__ . '/../../../TestData/TcPdfOutput/' . $name . '.svg.scissorsdown.pdf'
],
[
'layout' => (new PrintOptions())->setPrintable(false)->setDisplayTextDownArrows(true),
'layout' => (new DisplayOptions())->setPrintable(false)->setDisplayTextDownArrows(true),
'format' => QrCode::FILE_FORMAT_SVG,
'file' => __DIR__ . '/../../../TestData/TcPdfOutput/' . $name . '.svg.textarrows.pdf'
],
Expand Down Expand Up @@ -70,7 +70,7 @@ public function testValidQrBills(string $name, QrBill $qrBill): void

$output = (new TcPdfOutput($qrBill, 'en', $tcPdf));
$output
->setPrintOptions($variation['layout'])
->setDisplayOptions($variation['layout'])
->setQrCodeImageFormat($variation['format'])
->getPaymentPart();

Expand Down
Loading

0 comments on commit a95172d

Please sign in to comment.