Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaasuni committed Nov 22, 2024
1 parent e6ba1a0 commit bac7e86
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 22 deletions.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.3.2
2.4.0
2 changes: 1 addition & 1 deletion resources/debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion resources/rpm/rpm.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion src/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
33 changes: 23 additions & 10 deletions src/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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;
Expand All @@ -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 = '<?xml version="1.0" standalone="no" ?>' . "\n"
. '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">'
. "\n"
. '<svg'

$svg = '<svg'
. ' version="1.2"'
. ' baseProfile="full"'
. ' xmlns="http://www.w3.org/2000/svg"'
. ' xmlns:xlink="http://www.w3.org/1999/xlink"'
. ' xmlns:ev="http://www.w3.org/2001/xml-events"'
. ' width="' . $width . '"'
. ' height="' . $height . '"'
. ' viewBox="0 0 ' . $width . ' ' . $height . '"'
. ' version="1.1"'
. ' xmlns="http://www.w3.org/2000/svg"'
. '>' . "\n"
. "\t" . '<desc>' . htmlspecialchars($this->code, $hflag, 'UTF-8') . '</desc>' . "\n";
if ($this->bg_color_obj instanceof \Com\Tecnick\Color\Model\Rgb) {
Expand Down Expand Up @@ -371,6 +372,18 @@ public function getSvgCode(): string
. '</svg>' . "\n");
}

/**
* Get the barcode as SVG code, including the XML declaration.
*
* @return string SVG code
*/
public function getSvgCode(): string
{
return '<?xml version="1.0" standalone="no" ?>'
. "\n"
. $this->getInlineSvgCode();
}

/**
* Get an HTML representation of the barcode.
*
Expand Down
22 changes: 14 additions & 8 deletions test/BarcodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,15 @@ public function testExportMethods(): void

$svg = $type->setBackgroundColor('yellow')->getSvgCode();
$expected = '<?xml version="1.0" standalone="no" ?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="44.000000" height="8.000000"'
. ' viewBox="0 0 44.000000 8.000000" version="1.1" xmlns="http://www.w3.org/2000/svg">
<svg'
. ' version="1.2"'
. ' baseProfile="full"'
. ' xmlns="http://www.w3.org/2000/svg"'
. ' xmlns:xlink="http://www.w3.org/1999/xlink"'
. ' xmlns:ev="http://www.w3.org/2001/xml-events"'
. ' width="44.000000"'
. ' height="8.000000"'
. ' viewBox="0 0 44.000000 8.000000">
<desc>01001100011100001111,10110011100011110000</desc>
<rect x="0" y="0" width="44.000000" height="8.000000" fill="#ffff00"'
. ' stroke="none" stroke-width="0" stroke-linecap="square" />
Expand Down Expand Up @@ -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]
);

Expand All @@ -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]
);

Expand All @@ -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";',
Expand Down

0 comments on commit bac7e86

Please sign in to comment.