From bac7e86fb22c22dc69ae121337b77e4a7354793d Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Fri, 22 Nov 2024 20:25:11 +0000 Subject: [PATCH] Update dependencies --- Makefile | 5 +++++ VERSION | 2 +- resources/debian/control | 2 +- resources/rpm/rpm.spec | 2 +- src/Model.php | 9 ++++++++- src/Type.php | 33 +++++++++++++++++++++++---------- test/BarcodeTest.php | 22 ++++++++++++++-------- 7 files changed, 53 insertions(+), 22 deletions(-) diff --git a/Makefile b/Makefile index 26aad7c..239e74c 100644 --- a/Makefile +++ b/Makefile @@ -268,3 +268,8 @@ test: uninstall: rm -rf $(PATHINSTBIN) rm -rf $(PATHINSTDOC) + +# Increase the version patch number +.PHONY: versionup +versionup: + echo ${VERSION} | gawk -F. '{printf("%d.%d.%d\n",$$1,$$2,(($$3+1)));}' > VERSION diff --git a/VERSION b/VERSION index f90b1af..197c4d5 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.3.2 +2.4.0 diff --git a/resources/debian/control b/resources/debian/control index 466d3ad..982d1a4 100644 --- a/resources/debian/control +++ b/resources/debian/control @@ -10,7 +10,7 @@ Vcs-Git: https://github.com/~#VENDOR#~/~#PROJECT#~.git Package: ~#PKGNAME#~ Provides: php-~#PROJECT#~ Architecture: all -Depends: php (>= 8.0.0), php-bcmath, php-date, php-gd, php-tecnickcom-tc-lib-color (<< 3.0.0), php-tecnickcom-tc-lib-color (>= 2.2.4), ${misc:Depends} +Depends: php (>= 8.0.0), php-bcmath, php-date, php-gd, php-tecnickcom-tc-lib-color (<< 3.0.0), php-tecnickcom-tc-lib-color (>= 2.2.5), ${misc:Depends} Description: PHP Barcode library This library includes PHP classes to generate linear and bidimensional barcodes: diff --git a/resources/rpm/rpm.spec b/resources/rpm/rpm.spec index 990891b..c339698 100644 --- a/resources/rpm/rpm.spec +++ b/resources/rpm/rpm.spec @@ -18,7 +18,7 @@ BuildArch: noarch Requires: php(language) >= 8.0.0 Requires: php-composer(%{c_vendor}/tc-lib-color) < 3.0.0 -Requires: php-composer(%{c_vendor}/tc-lib-color) >= 2.2.4 +Requires: php-composer(%{c_vendor}/tc-lib-color) >= 2.2.5 Requires: php-bcmath Requires: php-date Requires: php-gd diff --git a/src/Model.php b/src/Model.php index b48b54c..2674583 100644 --- a/src/Model.php +++ b/src/Model.php @@ -112,7 +112,14 @@ public function getExtendedCode(): string; public function getSvg(?string $filename = null): void; /** - * Get the barcode as SVG code + * Get the barcode as inline SVG code. + * + * @return string Inline SVG code. + */ + public function getInlineSvgCode(): string; + + /** + * Get the barcode as SVG code, including the XML declaration. * * @return string SVG code */ diff --git a/src/Type.php b/src/Type.php index f46d06e..deb38f4 100644 --- a/src/Type.php +++ b/src/Type.php @@ -305,7 +305,7 @@ protected function getHTTPFile( } /** - * Get the barcode as SVG image object + * Get the barcode as SVG image object. * * @param string|null $filename The file name without extension (optional). * Only allows alphanumeric characters, underscores and hyphens. @@ -318,11 +318,11 @@ public function getSvg(?string $filename = null): void } /** - * Get the barcode as SVG code + * Get the barcode as inline SVG code. * - * @return string SVG code + * @return string Inline SVG code. */ - public function getSvgCode(): string + public function getInlineSvgCode(): string { // flags for htmlspecialchars $hflag = ENT_NOQUOTES; @@ -332,15 +332,16 @@ public function getSvgCode(): string $width = sprintf('%F', ($this->width + $this->padding['L'] + $this->padding['R'])); $height = sprintf('%F', ($this->height + $this->padding['T'] + $this->padding['B'])); - $svg = '' . "\n" - . '' - . "\n" - . '' . "\n" . "\t" . '' . htmlspecialchars($this->code, $hflag, 'UTF-8') . '' . "\n"; if ($this->bg_color_obj instanceof \Com\Tecnick\Color\Model\Rgb) { @@ -371,6 +372,18 @@ public function getSvgCode(): string . '' . "\n"); } + /** + * Get the barcode as SVG code, including the XML declaration. + * + * @return string SVG code + */ + public function getSvgCode(): string + { + return '' + . "\n" + . $this->getInlineSvgCode(); + } + /** * Get an HTML representation of the barcode. * diff --git a/test/BarcodeTest.php b/test/BarcodeTest.php index e877a78..ac0a6e8 100644 --- a/test/BarcodeTest.php +++ b/test/BarcodeTest.php @@ -175,9 +175,15 @@ public function testExportMethods(): void $svg = $type->setBackgroundColor('yellow')->getSvgCode(); $expected = ' - - + 01001100011100001111,10110011100011110000 @@ -306,10 +312,10 @@ public function testGetSvg(): void $type->getSvg(); $svg = ob_get_clean(); $this->assertNotFalse($svg); - $this->assertEquals('86e0362768e8b1b26032381232c0367f', md5($svg)); + $this->assertEquals('114f33435c265345f7c6cdf673922292', md5($svg)); $headers = xdebug_get_headers(); $this->assertEquals( - 'Content-Disposition: inline; filename="86e0362768e8b1b26032381232c0367f.svg";', + 'Content-Disposition: inline; filename="114f33435c265345f7c6cdf673922292.svg";', $headers[5] ); @@ -318,10 +324,10 @@ public function testGetSvg(): void $type->getSvg('#~'); $svg = ob_get_clean(); $this->assertNotFalse($svg); - $this->assertEquals('86e0362768e8b1b26032381232c0367f', md5($svg)); + $this->assertEquals('114f33435c265345f7c6cdf673922292', md5($svg)); $headers = xdebug_get_headers(); $this->assertEquals( - 'Content-Disposition: inline; filename="86e0362768e8b1b26032381232c0367f.svg";', + 'Content-Disposition: inline; filename="114f33435c265345f7c6cdf673922292.svg";', $headers[5] ); @@ -330,7 +336,7 @@ public function testGetSvg(): void $type->getSvg('test_SVG_filename-001'); $svg = ob_get_clean(); $this->assertNotFalse($svg); - $this->assertEquals('86e0362768e8b1b26032381232c0367f', md5($svg)); + $this->assertEquals('114f33435c265345f7c6cdf673922292', md5($svg)); $headers = xdebug_get_headers(); $this->assertEquals( 'Content-Disposition: inline; filename="test_SVG_filename-001.svg";',