Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ['8.2', '8.3', '8.4']
php-versions: ['8.3', '8.4', '8.5']
fail-fast: false
steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
}
],
"require": {
"php": "^8.2",
"php": "^8.3",
"bacon/bacon-qr-code": "^3.0"
},
"require-dev": {
Expand Down
2 changes: 2 additions & 0 deletions src/Writer/AbstractGdWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ protected function getMatrix(QrCodeInterface $qrCode): MatrixInterface
return $matrixFactory->create($qrCode);
}

#[\Override]
public function write(QrCodeInterface $qrCode, ?LogoInterface $logo = null, ?LabelInterface $label = null, array $options = []): ResultInterface
{
if (!extension_loaded('gd')) {
Expand Down Expand Up @@ -195,6 +196,7 @@ private function addLabel(LabelInterface $label, GdResult $result): GdResult
return new GdResult($result->getMatrix(), $targetImage);
}

#[\Override]
public function validateResult(ResultInterface $result, string $expectedData): void
{
$string = $result->getString();
Expand Down
1 change: 1 addition & 0 deletions src/Writer/BinaryWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

final readonly class BinaryWriter implements WriterInterface
{
#[\Override]
public function write(QrCodeInterface $qrCode, ?LogoInterface $logo = null, ?LabelInterface $label = null, array $options = []): ResultInterface
{
$matrixFactory = new MatrixFactory();
Expand Down
1 change: 1 addition & 0 deletions src/Writer/ConsoleWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

final readonly class ConsoleWriter implements WriterInterface
{
#[\Override]
public function write(QrCodeInterface $qrCode, ?LogoInterface $logo = null, ?LabelInterface $label = null, $options = []): ResultInterface
{
$matrixFactory = new MatrixFactory();
Expand Down
2 changes: 2 additions & 0 deletions src/Writer/DebugWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

final readonly class DebugWriter implements WriterInterface, ValidatingWriterInterface
{
#[\Override]
public function write(QrCodeInterface $qrCode, ?LogoInterface $logo = null, ?LabelInterface $label = null, array $options = []): ResultInterface
{
$matrixFactory = new MatrixFactory();
Expand All @@ -21,6 +22,7 @@ public function write(QrCodeInterface $qrCode, ?LogoInterface $logo = null, ?Lab
return new DebugResult($matrix, $qrCode, $logo, $label, $options);
}

#[\Override]
public function validateResult(ResultInterface $result, string $expectedData): void
{
if (!$result instanceof DebugResult) {
Expand Down
3 changes: 2 additions & 1 deletion src/Writer/EpsWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@

final readonly class EpsWriter implements WriterInterface
{
public const DECIMAL_PRECISION = 10;
public const int DECIMAL_PRECISION = 10;

#[\Override]
public function write(QrCodeInterface $qrCode, ?LogoInterface $logo = null, ?LabelInterface $label = null, array $options = []): ResultInterface
{
$matrixFactory = new MatrixFactory();
Expand Down
1 change: 1 addition & 0 deletions src/Writer/GifWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

final readonly class GifWriter extends AbstractGdWriter
{
#[\Override]
public function write(QrCodeInterface $qrCode, ?LogoInterface $logo = null, ?LabelInterface $label = null, array $options = []): ResultInterface
{
/** @var GdResult $gdResult */
Expand Down
11 changes: 6 additions & 5 deletions src/Writer/PdfWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@

final readonly class PdfWriter implements WriterInterface
{
public const WRITER_OPTION_UNIT = 'unit';
public const WRITER_OPTION_PDF = 'fpdf';
public const WRITER_OPTION_X = 'x';
public const WRITER_OPTION_Y = 'y';
public const WRITER_OPTION_LINK = 'link';
public const string WRITER_OPTION_UNIT = 'unit';
public const string WRITER_OPTION_PDF = 'fpdf';
public const string WRITER_OPTION_X = 'x';
public const string WRITER_OPTION_Y = 'y';
public const string WRITER_OPTION_LINK = 'link';

#[\Override]
public function write(QrCodeInterface $qrCode, ?LogoInterface $logo = null, ?LabelInterface $label = null, array $options = []): ResultInterface
{
$matrixFactory = new MatrixFactory();
Expand Down
5 changes: 3 additions & 2 deletions src/Writer/PngWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@

final readonly class PngWriter extends AbstractGdWriter
{
public const WRITER_OPTION_COMPRESSION_LEVEL = 'compression_level';
public const WRITER_OPTION_NUMBER_OF_COLORS = 'number_of_colors';
public const string WRITER_OPTION_COMPRESSION_LEVEL = 'compression_level';
public const string WRITER_OPTION_NUMBER_OF_COLORS = 'number_of_colors';

#[\Override]
public function write(QrCodeInterface $qrCode, ?LogoInterface $logo = null, ?LabelInterface $label = null, array $options = []): ResultInterface
{
if (!isset($options[self::WRITER_OPTION_COMPRESSION_LEVEL])) {
Expand Down
2 changes: 2 additions & 0 deletions src/Writer/Result/BinaryResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public function __construct(MatrixInterface $matrix)
parent::__construct($matrix);
}

#[\Override]
public function getString(): string
{
$matrix = $this->getMatrix();
Expand All @@ -28,6 +29,7 @@ public function getString(): string
return $binaryString;
}

#[\Override]
public function getMimeType(): string
{
return 'text/plain';
Expand Down
4 changes: 3 additions & 1 deletion src/Writer/Result/ConsoleResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

final class ConsoleResult extends AbstractResult
{
private const TWO_BLOCKS = [
private const array TWO_BLOCKS = [
0 => ' ',
1 => "\xe2\x96\x80",
2 => "\xe2\x96\x84",
Expand All @@ -36,11 +36,13 @@ public function __construct(
);
}

#[\Override]
public function getMimeType(): string
{
return 'text/plain';
}

#[\Override]
public function getString(): string
{
$matrix = $this->getMatrix();
Expand Down
2 changes: 2 additions & 0 deletions src/Writer/Result/DebugResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public function setValidateResult(bool $validateResult): void
$this->validateResult = $validateResult;
}

#[\Override]
public function getString(): string
{
$debugLines = [];
Expand Down Expand Up @@ -67,6 +68,7 @@ public function getString(): string
return implode("\n", $debugLines);
}

#[\Override]
public function getMimeType(): string
{
return 'text/plain';
Expand Down
2 changes: 2 additions & 0 deletions src/Writer/Result/EpsResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ public function __construct(
parent::__construct($matrix);
}

#[\Override]
public function getString(): string
{
return implode("\n", $this->lines);
}

#[\Override]
public function getMimeType(): string
{
return 'image/eps';
Expand Down
2 changes: 2 additions & 0 deletions src/Writer/Result/GdResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ public function getImage(): \GdImage
return $this->image;
}

#[\Override]
public function getString(): string
{
throw new \Exception('You can only use this method in a concrete implementation');
}

#[\Override]
public function getMimeType(): string
{
throw new \Exception('You can only use this method in a concrete implementation');
Expand Down
2 changes: 2 additions & 0 deletions src/Writer/Result/GifResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

final class GifResult extends GdResult
{
#[\Override]
public function getString(): string
{
ob_start();
Expand All @@ -14,6 +15,7 @@ public function getString(): string
return strval(ob_get_clean());
}

#[\Override]
public function getMimeType(): string
{
return 'image/gif';
Expand Down
2 changes: 2 additions & 0 deletions src/Writer/Result/PdfResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ public function getPdf(): \FPDF
return $this->fpdf;
}

#[\Override]
public function getString(): string
{
return $this->fpdf->Output('S');
}

#[\Override]
public function getMimeType(): string
{
return 'application/pdf';
Expand Down
2 changes: 2 additions & 0 deletions src/Writer/Result/PngResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public function __construct(
parent::__construct($matrix, $image);
}

#[\Override]
public function getString(): string
{
ob_start();
Expand All @@ -28,6 +29,7 @@ public function getString(): string
return strval(ob_get_clean());
}

#[\Override]
public function getMimeType(): string
{
return 'image/png';
Expand Down
2 changes: 2 additions & 0 deletions src/Writer/Result/SvgResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public function getXml(): \SimpleXMLElement
return $this->xml;
}

#[\Override]
public function getString(): string
{
$string = $this->xml->asXML();
Expand All @@ -36,6 +37,7 @@ public function getString(): string
return $string;
}

#[\Override]
public function getMimeType(): string
{
return 'image/svg+xml';
Expand Down
2 changes: 2 additions & 0 deletions src/Writer/Result/WebPResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public function __construct(
parent::__construct($matrix, $image);
}

#[\Override]
public function getString(): string
{
if (!function_exists('imagewebp')) {
Expand All @@ -28,6 +29,7 @@ public function getString(): string
return strval(ob_get_clean());
}

#[\Override]
public function getMimeType(): string
{
return 'image/webp';
Expand Down
15 changes: 8 additions & 7 deletions src/Writer/SvgWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@

final readonly class SvgWriter implements WriterInterface
{
public const DECIMAL_PRECISION = 2;
public const WRITER_OPTION_COMPACT = 'compact';
public const WRITER_OPTION_BLOCK_ID = 'block_id';
public const WRITER_OPTION_EXCLUDE_XML_DECLARATION = 'exclude_xml_declaration';
public const WRITER_OPTION_EXCLUDE_SVG_WIDTH_AND_HEIGHT = 'exclude_svg_width_and_height';
public const WRITER_OPTION_FORCE_XLINK_HREF = 'force_xlink_href';

public const int DECIMAL_PRECISION = 2;
public const string WRITER_OPTION_COMPACT = 'compact';
public const string WRITER_OPTION_BLOCK_ID = 'block_id';
public const string WRITER_OPTION_EXCLUDE_XML_DECLARATION = 'exclude_xml_declaration';
public const string WRITER_OPTION_EXCLUDE_SVG_WIDTH_AND_HEIGHT = 'exclude_svg_width_and_height';
public const string WRITER_OPTION_FORCE_XLINK_HREF = 'force_xlink_href';

#[\Override]
public function write(QrCodeInterface $qrCode, ?LogoInterface $logo = null, ?LabelInterface $label = null, array $options = []): ResultInterface
{
if (!isset($options[self::WRITER_OPTION_COMPACT])) {
Expand Down
3 changes: 2 additions & 1 deletion src/Writer/WebPWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@

final readonly class WebPWriter extends AbstractGdWriter
{
public const WRITER_OPTION_QUALITY = 'quality';
public const string WRITER_OPTION_QUALITY = 'quality';

#[\Override]
public function write(QrCodeInterface $qrCode, ?LogoInterface $logo = null, ?LabelInterface $label = null, array $options = []): ResultInterface
{
if (!isset($options[self::WRITER_OPTION_QUALITY])) {
Expand Down
Loading