From 4aec4d2c3cc78beb46d353b9aa8aab384bb46b9f Mon Sep 17 00:00:00 2001 From: codemasher Date: Sun, 22 Nov 2020 10:12:20 +0100 Subject: [PATCH] :bath: fix examples --- examples/MyCustomOutput.php | 2 +- examples/QRImageWithLogo.php | 10 +++++----- examples/custom_output.php | 5 +++-- examples/fpdf.php | 3 ++- examples/html.php | 7 ++++--- examples/image.php | 3 ++- examples/imageWithLogo.php | 15 ++++++++------- examples/imagick.php | 3 ++- examples/svg.php | 15 ++++++++------- examples/text.php | 5 +++-- 10 files changed, 38 insertions(+), 30 deletions(-) diff --git a/examples/MyCustomOutput.php b/examples/MyCustomOutput.php index 3664989b8..c48dcf912 100644 --- a/examples/MyCustomOutput.php +++ b/examples/MyCustomOutput.php @@ -20,7 +20,7 @@ class MyCustomOutput extends QROutputAbstract{ // TODO: Implement setModuleValues() method. } - public function dump(string $file = null){ + public function dump(string $file = null):string{ $output = ''; diff --git a/examples/QRImageWithLogo.php b/examples/QRImageWithLogo.php index f9d94ae34..9ba06815a 100644 --- a/examples/QRImageWithLogo.php +++ b/examples/QRImageWithLogo.php @@ -41,9 +41,9 @@ class QRImageWithLogo extends QRImage{ } $this->matrix->setLogoSpace( - $this->options->logoWidth, - $this->options->logoHeight - // not utilizing the position here + $this->options->logoSpaceWidth, + $this->options->logoSpaceHeight + // not utilizing the position here ); // there's no need to save the result of dump() into $this->image here @@ -56,8 +56,8 @@ class QRImageWithLogo extends QRImage{ $h = imagesy($im); // set new logo size, leave a border of 1 module - $lw = ($this->options->logoWidth - 2) * $this->options->scale; - $lh = ($this->options->logoHeight - 2) * $this->options->scale; + $lw = ($this->options->logoSpaceWidth - 2) * $this->options->scale; + $lh = ($this->options->logoSpaceHeight - 2) * $this->options->scale; // get the qrcode size $ql = $this->matrix->size() * $this->options->scale; diff --git a/examples/custom_output.php b/examples/custom_output.php index e21ce1073..f55f69b41 100644 --- a/examples/custom_output.php +++ b/examples/custom_output.php @@ -11,6 +11,7 @@ namespace chillerlan\QRCodeExamples; use chillerlan\QRCode\{QRCode, QROptions}; +use chillerlan\QRCode\Common\EccLevel; require_once __DIR__.'/../vendor/autoload.php'; @@ -19,7 +20,7 @@ $data = 'https://www.youtube.com/watch?v=DLzxrzFCyOs&t=43s'; // invoke the QROutputInterface manually $options = new QROptions([ 'version' => 5, - 'eccLevel' => QRCode::ECC_L, + 'eccLevel' => EccLevel::L, ]); $qrcode = new QRCode($options); @@ -33,7 +34,7 @@ var_dump($qrOutputInterface->dump()); // or just $options = new QROptions([ 'version' => 5, - 'eccLevel' => QRCode::ECC_L, + 'eccLevel' => EccLevel::L, 'outputType' => QRCode::OUTPUT_CUSTOM, 'outputInterface' => MyCustomOutput::class, ]); diff --git a/examples/fpdf.php b/examples/fpdf.php index 9c690a7f7..b231e49e0 100644 --- a/examples/fpdf.php +++ b/examples/fpdf.php @@ -3,6 +3,7 @@ namespace chillerlan\QRCodeExamples; use chillerlan\QRCode\{QRCode, QROptions}; +use chillerlan\QRCode\Common\EccLevel; require_once __DIR__ . '/../vendor/autoload.php'; @@ -11,7 +12,7 @@ $data = 'https://www.youtube.com/watch?v=DLzxrzFCyOs&t=43s'; $options = new QROptions([ 'version' => 7, 'outputType' => QRCode::OUTPUT_FPDF, - 'eccLevel' => QRCode::ECC_L, + 'eccLevel' => EccLevel::L, 'scale' => 5, 'imageBase64' => false, 'moduleValues' => [ diff --git a/examples/html.php b/examples/html.php index aa5305d24..34140671c 100644 --- a/examples/html.php +++ b/examples/html.php @@ -11,6 +11,7 @@ namespace chillerlan\QRCodeExamples; use chillerlan\QRCode\{QRCode, QROptions}; +use chillerlan\QRCode\Common\EccLevel; require_once '../vendor/autoload.php'; @@ -60,9 +61,9 @@ header('Content-Type: text/html; charset=utf-8'); $data = 'https://www.youtube.com/watch?v=DLzxrzFCyOs&t=43s'; $options = new QROptions([ - 'version' => 5, - 'outputType' => QRCode::OUTPUT_MARKUP_HTML, - 'eccLevel' => QRCode::ECC_L, + 'version' => 5, + 'outputType' => QRCode::OUTPUT_MARKUP_HTML, + 'eccLevel' => EccLevel::L, 'moduleValues' => [ // finder 1536 => '#A71111', // dark (true) diff --git a/examples/image.php b/examples/image.php index 54426c68a..99d3ceab8 100644 --- a/examples/image.php +++ b/examples/image.php @@ -11,6 +11,7 @@ namespace chillerlan\QRCodeExamples; use chillerlan\QRCode\{QRCode, QROptions}; +use chillerlan\QRCode\Common\EccLevel; require_once __DIR__.'/../vendor/autoload.php'; @@ -19,7 +20,7 @@ $data = 'https://www.youtube.com/watch?v=DLzxrzFCyOs&t=43s'; $options = new QROptions([ 'version' => 10, 'outputType' => QRCode::OUTPUT_IMAGE_PNG, - 'eccLevel' => QRCode::ECC_H, + 'eccLevel' => EccLevel::L, 'scale' => 5, 'imageBase64' => false, 'moduleValues' => [ diff --git a/examples/imageWithLogo.php b/examples/imageWithLogo.php index bfdf11f42..622c74bed 100644 --- a/examples/imageWithLogo.php +++ b/examples/imageWithLogo.php @@ -11,28 +11,29 @@ namespace chillerlan\QRCodeExamples; use chillerlan\QRCode\{QRCode, QROptions}; +use chillerlan\QRCode\Common\EccLevel; require_once __DIR__.'/../vendor/autoload.php'; $data = 'https://www.youtube.com/watch?v=DLzxrzFCyOs&t=43s'; /** - * @property int $logoWidth - * @property int $logoHeight + * @property int $logoSpaceWidth + * @property int $logoSpaceHeight * * @noinspection PhpIllegalPsrClassPathInspection */ class LogoOptions extends QROptions{ - protected int $logoWidth; - protected int $logoHeight; + protected int $logoSpaceWidth; + protected int $logoSpaceHeight; } $options = new LogoOptions; $options->version = 7; -$options->eccLevel = QRCode::ECC_H; +$options->eccLevel = EccLevel::H; $options->imageBase64 = false; -$options->logoWidth = 13; -$options->logoHeight = 13; +$options->logoSpaceWidth = 13; +$options->logoSpaceHeight = 13; $options->scale = 5; $options->imageTransparent = false; diff --git a/examples/imagick.php b/examples/imagick.php index 6bec4d02e..38162972f 100644 --- a/examples/imagick.php +++ b/examples/imagick.php @@ -11,6 +11,7 @@ namespace chillerlan\QRCodeExamples; use chillerlan\QRCode\{QRCode, QROptions}; +use chillerlan\QRCode\Common\EccLevel; require_once __DIR__.'/../vendor/autoload.php'; @@ -19,7 +20,7 @@ $data = 'https://www.youtube.com/watch?v=DLzxrzFCyOs&t=43s'; $options = new QROptions([ 'version' => 7, 'outputType' => QRCode::OUTPUT_IMAGICK, - 'eccLevel' => QRCode::ECC_L, + 'eccLevel' => EccLevel::L, 'scale' => 5, 'moduleValues' => [ // finder diff --git a/examples/svg.php b/examples/svg.php index a7a159d70..e8dd5ad12 100644 --- a/examples/svg.php +++ b/examples/svg.php @@ -11,6 +11,7 @@ namespace chillerlan\QRCodeExamples; use chillerlan\QRCode\{QRCode, QROptions}; +use chillerlan\QRCode\Common\EccLevel; require_once __DIR__.'/../vendor/autoload.php'; @@ -18,14 +19,14 @@ $data = 'https://www.youtube.com/watch?v=DLzxrzFCyOs&t=43s'; $gzip = true; $options = new QROptions([ - 'version' => 7, - 'outputType' => QRCode::OUTPUT_MARKUP_SVG, - 'eccLevel' => QRCode::ECC_L, + 'version' => 7, + 'outputType' => QRCode::OUTPUT_MARKUP_SVG, + 'eccLevel' => EccLevel::L, 'svgViewBoxSize' => 530, - 'addQuietzone' => true, - 'cssClass' => 'my-css-class', - 'svgOpacity' => 1.0, - 'svgDefs' => ' + 'addQuietzone' => true, + 'cssClass' => 'my-css-class', + 'svgOpacity' => 1.0, + 'svgDefs' => ' diff --git a/examples/text.php b/examples/text.php index 9bdf154f0..d0a6ec2bc 100644 --- a/examples/text.php +++ b/examples/text.php @@ -11,6 +11,7 @@ namespace chillerlan\QRCodeExamples; use chillerlan\QRCode\{QRCode, QROptions}; +use chillerlan\QRCode\Common\EccLevel; require_once __DIR__.'/../vendor/autoload.php'; @@ -19,7 +20,7 @@ $data = 'https://www.youtube.com/watch?v=DLzxrzFCyOs&t=43s'; $options = new QROptions([ 'version' => 5, 'outputType' => QRCode::OUTPUT_STRING_TEXT, - 'eccLevel' => QRCode::ECC_L, + 'eccLevel' => EccLevel::L, ]); //
 to view it in a browser
@@ -30,7 +31,7 @@ echo '
'.(new QRCode($options))->ren
 $options = new QROptions([
 	'version'      => 5,
 	'outputType'   => QRCode::OUTPUT_STRING_TEXT,
-	'eccLevel'     => QRCode::ECC_L,
+	'eccLevel'     => EccLevel::L,
 	'moduleValues' => [
 		// finder
 		1536 => 'A', // dark (true)