Code128
extends AbstractAdapter
in package
Table of Contents
Properties
- $options : array<string|int, mixed>
- Allowed options for this adapter
- $utf8StringWrapper : StringWrapperInterface
- The used string wrapper used for basic UTF-8 string functions
Methods
- __construct() : mixed
- Constructor for this barcode adapter
- getCharacters() : int|string|array<string|int, mixed>
- Returns the allowed characters
- getChecksum() : string
- Returns the checksum function name
- getLength() : int|array<string|int, mixed>
- Returns the allowed barcode length
- getUtf8StringWrapper() : StringWrapperInterface
- Get the string wrapper supporting UTF-8 character encoding
- hasValidCharacters() : bool
- Checks for allowed characters within the barcode
- hasValidChecksum() : bool
- Validates the checksum
- hasValidLength() : bool
- Checks the length of a barcode
- setUtf8StringWrapper() : void
- useChecksum() : AbstractAdapter|bool
- Sets the checksum validation, if no value is given, the actual setting is returned
- chr128() : int|string
- Internal Method to return the ascii value from a code128 integer
- code128() : bool
- Validates the checksum ()
- code25() : bool
- Validates the checksum (Modulo 10) CODE25 implementation factor 3
- getCodingSet() : string
- Returns the coding set for a barcode
- gtin() : bool
- Validates the checksum (Modulo 10) GTIN implementation factor 3
- identcode() : bool
- Validates the checksum (Modulo 10) IDENTCODE implementation factors 9 and 4
- ord128() : int
- Internal method to return the code128 integer from an ascii value
- postnet() : bool
- Validates the checksum () POSTNET implementation
- setCharacters() : $this
- Sets the allowed characters of this barcode
- setChecksum() : $this
- Sets the checksum validation method
- setLength() : $this
- Sets the length of this barcode
Properties
$options
Allowed options for this adapter
protected
array<string|int, mixed>
$options
= [
'length' => null,
// Allowed barcode lengths, integer, array, string
'characters' => null,
// Allowed barcode characters
'checksum' => null,
// Callback to checksum function
'useChecksum' => true,
]
$utf8StringWrapper
The used string wrapper used for basic UTF-8 string functions
protected
StringWrapperInterface
$utf8StringWrapper
Methods
__construct()
Constructor for this barcode adapter
public
__construct() : mixed
getCharacters()
Returns the allowed characters
public
getCharacters() : int|string|array<string|int, mixed>
Return values
int|string|array<string|int, mixed>getChecksum()
Returns the checksum function name
public
getChecksum() : string
Return values
stringgetLength()
Returns the allowed barcode length
public
getLength() : int|array<string|int, mixed>
Return values
int|array<string|int, mixed>getUtf8StringWrapper()
Get the string wrapper supporting UTF-8 character encoding
public
getUtf8StringWrapper() : StringWrapperInterface
Return values
StringWrapperInterfacehasValidCharacters()
Checks for allowed characters within the barcode
public
hasValidCharacters(string $value) : bool
Parameters
- $value : string
-
The barcode to check for allowed characters
Return values
boolhasValidChecksum()
Validates the checksum
public
hasValidChecksum(string $value) : bool
Parameters
- $value : string
-
The barcode to check the checksum for
Return values
boolhasValidLength()
Checks the length of a barcode
public
hasValidLength(string $value) : bool
Parameters
- $value : string
-
The barcode to check for proper length
Return values
boolsetUtf8StringWrapper()
public
setUtf8StringWrapper(StringWrapperInterface $utf8StringWrapper) : void
Parameters
- $utf8StringWrapper : StringWrapperInterface
useChecksum()
Sets the checksum validation, if no value is given, the actual setting is returned
public
useChecksum([bool $check = null ]) : AbstractAdapter|bool
Parameters
- $check : bool = null
Return values
AbstractAdapter|boolchr128()
Internal Method to return the ascii value from a code128 integer
protected
chr128(int $value, string $set) : int|string
Table A ASCII CODE128 32 to 95 == 0 to 63 0 to 31 == 64 to 95 128 to 138 == 96 to 106
Table B ASCII CODE128 32 to 138 == 0 to 106
Table C ASCII CODE128 "00" to "99" == 0 to 99 132 to 138 == 100 to 106
Parameters
- $value : int
- $set : string
Return values
int|stringcode128()
Validates the checksum ()
protected
code128(string $value) : bool
Parameters
- $value : string
-
The barcode to validate
Return values
boolcode25()
Validates the checksum (Modulo 10) CODE25 implementation factor 3
protected
code25(string $value) : bool
Parameters
- $value : string
-
The barcode to validate
Return values
boolgetCodingSet()
Returns the coding set for a barcode
protected
getCodingSet(string $value) : string
Parameters
- $value : string
-
Barcode
Return values
stringgtin()
Validates the checksum (Modulo 10) GTIN implementation factor 3
protected
gtin(string $value) : bool
Parameters
- $value : string
-
The barcode to validate
Return values
boolidentcode()
Validates the checksum (Modulo 10) IDENTCODE implementation factors 9 and 4
protected
identcode(string $value) : bool
Parameters
- $value : string
-
The barcode to validate
Return values
boolord128()
Internal method to return the code128 integer from an ascii value
protected
ord128(string $value, string $set) : int
Table A ASCII CODE128 32 to 95 == 0 to 63 0 to 31 == 64 to 95 128 to 138 == 96 to 106
Table B ASCII CODE128 32 to 138 == 0 to 106
Table C ASCII CODE128 "00" to "99" == 0 to 99 132 to 138 == 100 to 106
Parameters
- $value : string
- $set : string
Return values
intpostnet()
Validates the checksum () POSTNET implementation
protected
postnet(string $value) : bool
Parameters
- $value : string
-
The barcode to validate
Return values
boolsetCharacters()
Sets the allowed characters of this barcode
protected
setCharacters(int $characters) : $this
Parameters
- $characters : int
Return values
$thissetChecksum()
Sets the checksum validation method
protected
setChecksum(callable $checksum) : $this
Parameters
- $checksum : callable
-
Checksum method to call
Return values
$thissetLength()
Sets the length of this barcode
protected
setLength(int|array<string|int, mixed> $length) : $this
Parameters
- $length : int|array<string|int, mixed>