Skip to content

Phpunit fix #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/ApplicationIdentifiers.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
51 changes: 51 additions & 0 deletions src/Identifiers/ConsumerVariantIdentifier.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
declare(strict_types=1);

namespace NGT\Barcode\GS1Decoder\Identifiers;

use NGT\Barcode\GS1Decoder\Contracts\Identifiers\VariableLength;
use NGT\Barcode\GS1Decoder\Identifiers\Abstracts\Identifier;

class ConsumerVariantIdentifier extends Identifier implements VariableLength
{
/**
* @inheritDoc
*/
public function getTitle(): string
{
return 'CONSUMER VARIANT';
}

/**
* @inheritDoc
*/
public function getName(): string
{
return 'Consumer product variant';
}

/**
* @inheritDoc
*/
public function getCode(): string
{
return '22';
}

/**
* @inheritDoc
*/
public function getLength(): int
{
return 20;
}

/**
* @inheritDoc
*/
public function getFormat(): string
{
return $this->standardFormat('1,20');
}
}

51 changes: 51 additions & 0 deletions src/Identifiers/VariableCountIdentifier.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
declare(strict_types=1);

namespace NGT\Barcode\GS1Decoder\Identifiers;

use NGT\Barcode\GS1Decoder\Contracts\Identifiers\VariableLength;
use NGT\Barcode\GS1Decoder\Identifiers\Abstracts\Identifier;

class VariableCountIdentifier extends Identifier implements VariableLength
{
/**
* @inheritDoc
*/
public function getTitle(): string
{
return 'VAR. COUNT';
}

/**
* @inheritDoc
*/
public function getName(): string
{
return 'Variable count of items';
}

/**
* @inheritDoc
*/
public function getCode(): string
{
return '30';
}

/**
* @inheritDoc
*/
public function getLength(): int
{
return 8;
}

/**
* @inheritDoc
*/
public function getFormat(): string
{
return '/^\d{1,8}$/';
}
}

12 changes: 11 additions & 1 deletion tests/Integration/DecodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down