Skip to content

Commit 61cc3ef

Browse files
committed
Update compatibility
1 parent 393fec6 commit 61cc3ef

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+316
-709
lines changed

.github/workflows/CI.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
runs-on: ubuntu-latest
88
strategy:
99
matrix:
10-
php-versions: ['8.1', '8.2', '8.3']
10+
php-versions: ['8.2', '8.3', '8.4']
1111
fail-fast: false
1212
steps:
1313
- uses: actions/checkout@v4

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright 2023 (c) Jeroen van den Enden
1+
Copyright 2024 (c) Jeroen van den Enden
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy
44
of this software and associated documentation files (the "Software"), to deal

README.md

+39-32
Original file line numberDiff line numberDiff line change
@@ -34,27 +34,29 @@ use Endroid\QrCode\Builder\Builder;
3434
use Endroid\QrCode\Encoding\Encoding;
3535
use Endroid\QrCode\ErrorCorrectionLevel;
3636
use Endroid\QrCode\Label\LabelAlignment;
37-
use Endroid\QrCode\Label\Font\NotoSans;
37+
use Endroid\QrCode\Label\Font\OpenSans;
3838
use Endroid\QrCode\RoundBlockSizeMode;
3939
use Endroid\QrCode\Writer\PngWriter;
4040

41-
$result = Builder::create()
42-
->writer(new PngWriter())
43-
->writerOptions([])
44-
->data('Custom QR code contents')
45-
->encoding(new Encoding('UTF-8'))
46-
->errorCorrectionLevel(ErrorCorrectionLevel::High)
47-
->size(300)
48-
->margin(10)
49-
->roundBlockSizeMode(RoundBlockSizeMode::Margin)
50-
->logoPath(__DIR__.'/assets/symfony.png')
51-
->logoResizeToWidth(50)
52-
->logoPunchoutBackground(true)
53-
->labelText('This is the label')
54-
->labelFont(new NotoSans(20))
55-
->labelAlignment(LabelAlignment::Center)
56-
->validateResult(false)
57-
->build();
41+
$builder = new Builder(
42+
writer: new PngWriter(),
43+
writerOptions: [],
44+
validateResult: false,
45+
data: 'Custom QR code contents',
46+
encoding: new Encoding('UTF-8'),
47+
errorCorrectionLevel: ErrorCorrectionLevel::High,
48+
size: 300,
49+
margin: 10,
50+
roundBlockSizeMode: RoundBlockSizeMode::Margin,
51+
logoPath: __DIR__.'/assets/symfony.png',
52+
logoResizeToWidth: 50,
53+
logoPunchoutBackground: true,
54+
labelText: 'This is the label',
55+
labelFont: new OpenSans(20),
56+
labelAlignment: LabelAlignment::Center
57+
);
58+
59+
$result = $builder->build();
5860
```
5961

6062
## Usage: without using the builder
@@ -73,24 +75,29 @@ use Endroid\QrCode\Writer\ValidationException;
7375
$writer = new PngWriter();
7476

7577
// Create QR code
76-
$qrCode = QrCode::create('Life is too short to be generating QR codes')
77-
->setEncoding(new Encoding('UTF-8'))
78-
->setErrorCorrectionLevel(ErrorCorrectionLevel::Low)
79-
->setSize(300)
80-
->setMargin(10)
81-
->setRoundBlockSizeMode(RoundBlockSizeMode::Margin)
82-
->setForegroundColor(new Color(0, 0, 0))
83-
->setBackgroundColor(new Color(255, 255, 255));
78+
$qrCode = new QrCode(
79+
data: 'Life is too short to be generating QR codes',
80+
encoding: new Encoding('UTF-8'),
81+
errorCorrectionLevel: ErrorCorrectionLevel::Low,
82+
size: 300,
83+
margin: 10,
84+
roundBlockSizeMode: RoundBlockSizeMode::Margin,
85+
foregroundColor: new Color(0, 0, 0),
86+
backgroundColor: new Color(255, 255, 255)
87+
);
8488

8589
// Create generic logo
86-
$logo = Logo::create(__DIR__.'/assets/symfony.png')
87-
->setResizeToWidth(50)
88-
->setPunchoutBackground(true)
89-
;
90+
$logo = new Logo(
91+
path: __DIR__.'/assets/symfony.png',
92+
resizeToWidth: 50,
93+
punchoutBackground: true
94+
);
9095

9196
// Create generic label
92-
$label = Label::create('Label')
93-
->setTextColor(new Color(255, 0, 0));
97+
$label = new Label(
98+
text: 'Label',
99+
textColor: new Color(255, 0, 0)
100+
);
94101

95102
$result = $writer->write($qrCode, $logo, $label);
96103

assets/noto_sans.otf

-15.7 MB
Binary file not shown.

composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
}
1313
],
1414
"require": {
15-
"php": "^8.1",
15+
"php": "^8.2",
1616
"bacon/bacon-qr-code": "^3.0"
1717
},
1818
"require-dev": {
@@ -48,7 +48,7 @@
4848
},
4949
"extra": {
5050
"branch-alias": {
51-
"dev-main": "5.x-dev"
51+
"dev-main": "6.x-dev"
5252
}
5353
}
5454
}

src/Bacon/ErrorCorrectionLevelConverter.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
use BaconQrCode\Common\ErrorCorrectionLevel as BaconErrorCorrectionLevel;
88
use Endroid\QrCode\ErrorCorrectionLevel;
99

10-
final class ErrorCorrectionLevelConverter
10+
final readonly class ErrorCorrectionLevelConverter
1111
{
1212
public static function convertToBaconErrorCorrectionLevel(ErrorCorrectionLevel $errorCorrectionLevel): BaconErrorCorrectionLevel
1313
{
1414
return match ($errorCorrectionLevel) {
1515
ErrorCorrectionLevel::Low => BaconErrorCorrectionLevel::valueOf('L'),
1616
ErrorCorrectionLevel::Medium => BaconErrorCorrectionLevel::valueOf('M'),
1717
ErrorCorrectionLevel::Quartile => BaconErrorCorrectionLevel::valueOf('Q'),
18-
ErrorCorrectionLevel::High => BaconErrorCorrectionLevel::valueOf('H')
18+
ErrorCorrectionLevel::High => BaconErrorCorrectionLevel::valueOf('H'),
1919
};
2020
}
2121
}

src/Bacon/MatrixFactory.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Endroid\QrCode\Matrix\MatrixInterface;
1111
use Endroid\QrCode\QrCodeInterface;
1212

13-
final class MatrixFactory implements MatrixFactoryInterface
13+
final readonly class MatrixFactory implements MatrixFactoryInterface
1414
{
1515
public function create(QrCodeInterface $qrCode): MatrixInterface
1616
{

0 commit comments

Comments
 (0)