mirror of
https://github.com/Karaka-Management/oms-Labeling.git
synced 2026-02-11 07:18:39 +00:00
fix tests
This commit is contained in:
parent
25a81b7101
commit
a06c6c8c6d
|
|
@ -550,6 +550,13 @@ class GS1Datamatrix
|
||||||
|
|
||||||
public array $data = [];
|
public array $data = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate GS1 data
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
public function validate() : bool
|
public function validate() : bool
|
||||||
{
|
{
|
||||||
if (empty($this->data['01'] ?? '')) {
|
if (empty($this->data['01'] ?? '')) {
|
||||||
|
|
@ -565,6 +572,13 @@ class GS1Datamatrix
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render GS1 string representation
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
public function renderString() : string
|
public function renderString() : string
|
||||||
{
|
{
|
||||||
$text = '';
|
$text = '';
|
||||||
|
|
@ -576,6 +590,13 @@ class GS1Datamatrix
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render internal GS1 string used for datamatrix etc.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
public function renderCodeString() : string
|
public function renderCodeString() : string
|
||||||
{
|
{
|
||||||
// 232 = FNC1 = ]C1
|
// 232 = FNC1 = ]C1
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,13 @@ class Label
|
||||||
|
|
||||||
public array $elements = [];
|
public array $elements = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render label
|
||||||
|
*
|
||||||
|
* @return null|\GdImage
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
public function render() : ?\GdImage
|
public function render() : ?\GdImage
|
||||||
{
|
{
|
||||||
$im = \imagecreatetruecolor((int) (37.8 * $this->width), (int) (37.8 * $this->height));
|
$im = \imagecreatetruecolor((int) (37.8 * $this->width), (int) (37.8 * $this->height));
|
||||||
|
|
@ -58,6 +65,7 @@ class Label
|
||||||
foreach ($this->elements as $element) {
|
foreach ($this->elements as $element) {
|
||||||
$color = 0;
|
$color = 0;
|
||||||
|
|
||||||
|
// @todo: replace int type with enum
|
||||||
if ($element instanceof Shape) {
|
if ($element instanceof Shape) {
|
||||||
if ($element->type === 1) {
|
if ($element->type === 1) {
|
||||||
// Line
|
// Line
|
||||||
|
|
@ -88,9 +96,9 @@ class Label
|
||||||
$bg
|
$bg
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} elseif ($element->type === 3) {
|
|
||||||
} elseif ($element->type === 4) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @todo: implement circle + elipse
|
||||||
} elseif ($element instanceof Text) {
|
} elseif ($element instanceof Text) {
|
||||||
\imagettftext($im, $element->size, 0, $element->x, $element->y, $color, $element->font, $element->text);
|
\imagettftext($im, $element->size, 0, $element->x, $element->y, $color, $element->font, $element->text);
|
||||||
} elseif ($element instanceof Image) {
|
} elseif ($element instanceof Image) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user