From 13b3db466318e9a3a2ac6fa8520f3ef7cba6a4a7 Mon Sep 17 00:00:00 2001 From: Tony Diaz Date: Wed, 17 Aug 2022 08:06:56 -0600 Subject: [PATCH 1/3] Added Consumer Variant Identifier (22) and Variant Count Identifier (30). --- src/ApplicationIdentifiers.php | 4 +- src/Identifiers/ConsumerVariantIdentifier.php | 50 ++++++++++++++++++ src/Identifiers/VariableCountIdentifier.php | 51 +++++++++++++++++++ 3 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 src/Identifiers/ConsumerVariantIdentifier.php create mode 100644 src/Identifiers/VariableCountIdentifier.php diff --git a/src/ApplicationIdentifiers.php b/src/ApplicationIdentifiers.php index 88481ca..50afbc4 100644 --- a/src/ApplicationIdentifiers.php +++ b/src/ApplicationIdentifiers.php @@ -24,7 +24,9 @@ class ApplicationIdentifiers Identifiers\SellByDateIdentifier::class, // 16 Identifiers\ExpirationDateIdentifier::class, // 17 Identifiers\VariantIdentifier::class, // 20 - Identifiers\SerialNumberIdentifier::class, // 21 + Identifiers\SerialNumberIdentifier::class, // 21 + Identifiers\ConsumerVariantIdentifier::class, // 22 + Identifiers\VariableCountIdentifier::class, // 30 Identifiers\CompanyInternalInformationIdentifier::class, // 91 Identifiers\OriginIdentifier::class, // 422 diff --git a/src/Identifiers/ConsumerVariantIdentifier.php b/src/Identifiers/ConsumerVariantIdentifier.php new file mode 100644 index 0000000..32558e2 --- /dev/null +++ b/src/Identifiers/ConsumerVariantIdentifier.php @@ -0,0 +1,50 @@ +standardFormat('1,20'); + } +} + diff --git a/src/Identifiers/VariableCountIdentifier.php b/src/Identifiers/VariableCountIdentifier.php new file mode 100644 index 0000000..20fbf6b --- /dev/null +++ b/src/Identifiers/VariableCountIdentifier.php @@ -0,0 +1,51 @@ +standardFormat('1,8'); + } +} + From 058d7e1e2893238c4fc2b25e4c8c7c392fa36af5 Mon Sep 17 00:00:00 2001 From: Tony Diaz Date: Wed, 17 Aug 2022 08:17:59 -0600 Subject: [PATCH 2/3] Changed format for Variable Count to digits (1-8 length), and updated DecodeTest to include codes 22 (Consumer product variant) and 30 (Variant count of items). --- src/Identifiers/VariableCountIdentifier.php | 4 ++-- tests/Integration/DecodeTest.php | 12 +++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/Identifiers/VariableCountIdentifier.php b/src/Identifiers/VariableCountIdentifier.php index 20fbf6b..6066494 100644 --- a/src/Identifiers/VariableCountIdentifier.php +++ b/src/Identifiers/VariableCountIdentifier.php @@ -21,7 +21,7 @@ public function getTitle(): string */ public function getName(): string { - return 'Quantity or Units'; + return 'Variable count of items'; } /** @@ -45,7 +45,7 @@ public function getLength(): int */ public function getFormat(): string { - return $this->standardFormat('1,8'); + return '/^\d{1,8}$/'; } } diff --git a/tests/Integration/DecodeTest.php b/tests/Integration/DecodeTest.php index 36b0302..19af353 100644 --- a/tests/Integration/DecodeTest.php +++ b/tests/Integration/DecodeTest.php @@ -120,7 +120,17 @@ public function getBarcodes(): array '01006141410073491714123110A12345B[FNC1]211234ABC[FNC1]', '21', '1234ABC', - ], + ], + 'Consumer product variant' => [ + '01006141410073491714123110A12345B[FNC1]22ABC1234[FNC1]', + '22', + 'ABC1234' + ], + 'Variable count of items [Numeric]' => [ + '01006141410073491714123110A12345B[FNC1]300100[FNC1]', + '30', + '0100' + ], 'Company internal information' => [ '01087106420356209135[FNC1]', '91', From 1b8c6e5703d14db3743d397b189225b378418101 Mon Sep 17 00:00:00 2001 From: Tony Diaz Date: Fri, 19 Aug 2022 08:43:53 -0500 Subject: [PATCH 3/3] Determined the unit test was correct, but forgot to implement the VariableLength class on the ConsumerVariantIdentifier. --- src/Identifiers/ConsumerVariantIdentifier.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Identifiers/ConsumerVariantIdentifier.php b/src/Identifiers/ConsumerVariantIdentifier.php index 32558e2..b53b7a8 100644 --- a/src/Identifiers/ConsumerVariantIdentifier.php +++ b/src/Identifiers/ConsumerVariantIdentifier.php @@ -3,9 +3,10 @@ namespace NGT\Barcode\GS1Decoder\Identifiers; +use NGT\Barcode\GS1Decoder\Contracts\Identifiers\VariableLength; use NGT\Barcode\GS1Decoder\Identifiers\Abstracts\Identifier; -class ConsumerVariantIdentifier extends Identifier +class ConsumerVariantIdentifier extends Identifier implements VariableLength { /** * @inheritDoc