GsOneElementString

GS1 Application Identifier element strings (GS1 General Specifications) Reads the bracketed form "(ai)value(ai)value...", which is also the human readable interpretation, and checks the Application Id

Namespace: Com\Tecnick\Barcode\Type

class GsOneElementString

Source: src/Type/GsOneElementString.php:46

GS1 Application Identifier element strings (GS1 General Specifications)

Reads the bracketed form “(ai)value(ai)value…”, which is also the human readable interpretation, and checks the Application Identifier syntax, the encodable character set 82 and the predefined element string lengths. Parentheses are reserved as Application Identifier delimiters and cannot appear in a value. Element strings whose Application Identifier is not listed in PREDEFINED are of variable length and need an FNC1 separator unless they are last.

GS1 is a registered trademark of GS1 AISBL.

Constants

CSET82

GS1 Application Identifier encodable character set 82 (the GS1 subset of ISO/IEC 646)

public const CSET82 = '!"%&\'()*+,-./0123456789:;<=>?ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz'

Source: src/Type/GsOneElementString.php:54

PREDEFINED

Total length of the element strings with a predefined length, keyed by the first two digits of the Application Identifier. Every other Application Identifier is of variable length and needs an FNC1 separator.

public const PREDEFINED = ['00' => 20, '01' => 16, '02' => 16, '03' => 16, '04' => 18, '11' => 8, '12' => 8, '13' => 8, '14' => 8, '15' => 8, '16' => 8, '17' => 8, '18' => 8, '19' => 8, '20' => 4, '31' => 10, '32' => 10, '33' => 10, '34' => 10, '35' => 10, '36' => 10, '41' => 16]

Source: src/Type/GsOneElementString.php:63

Methods

getCheckDigit()

Calculate the GS1 modulo 10 check digit of a numeric string.

The rightmost data digit has weight 3 and the weights alternate to the left.

public getCheckDigit(string $code): int

Parameters:

  • $code (string): Data digits without the check digit

Returns: int

Source: src/Type/GsOneElementString.php:94

getData()

Get the character sequence of the element strings, with a separator after every variable length element string that is not the last one.

public getData(array<int,array{string, string}> $elements, string $separator): string

Parameters:

  • $elements (array<int,array{string, string}>): Application Identifier and value pairs
  • $separator (string): Function 1 Symbol Character

Returns: string

Source: src/Type/GsOneElementString.php:238

getHumanReadable()

Get the human readable interpretation of the element strings.

public getHumanReadable(array<int,array{string, string}> $elements): string

Parameters:

  • $elements (array<int,array{string, string}>): Application Identifier and value pairs

Returns: string

Source: src/Type/GsOneElementString.php:221

hasPredefinedLength()

True when the element string of the given Application Identifier has a predefined length and needs no FNC1 separator.

public hasPredefinedLength(string $appid): bool

Parameters:

  • $appid (string): Application Identifier digits, without brackets

Returns: bool

Source: src/Type/GsOneElementString.php:211

parse()

Split the bracketed code into Application Identifier and value pairs.

public parse(string $code): array<int,array{string, string}>

Parameters:

  • $code (string): Bracketed element strings

Returns: array<int,array{string, string}>

Throws:

  • Exception: if the bracketed form is malformed or cannot be encoded

Source: src/Type/GsOneElementString.php:114

validate()

Check an Application Identifier and its value.

public validate(string $appid, string $value): void

Parameters:

  • $appid (string): Application Identifier digits, without brackets
  • $value (string): Data field of the element string

Throws:

  • Exception: if the element string cannot be encoded

Source: src/Type/GsOneElementString.php:156