tiendanube / gtinvalidation
Validates GTIN product codes.
v1.0
2018-07-25 22:31 UTC
Requires
- php: >=5.4
Requires (Dev)
- phpunit/phpunit: 4.6.*
This package is not auto-updated.
Last update: 2026-03-07 16:40:44 UTC
README
GtinValidation is a library for validating the format and check digit of a GTIN.
Requirements
- PHP 5.4 or higher
Installation
You can find GtinValidation on Packagist. To install GtinValidation in Composer:
{
"require": {
"tiendanube/gtinvalidation": "dev-master"
}
}
Usage
Basic check
To check a GTIN's validity:
<?php use GtinValidation\GtinValidator; $gtinValidator = new GtinValidator('0000000000000'); echo $gtinValidator->isValid();
Output
false
Advanced Check
To get more detailed information about the GTIN and its validity, retrieve the GTIN object:
<?php use GtinValidation\GtinValidator; $gtinValidator = new GtinValidator('0000000000000'); $gtinObject = $gtinValidator->getGtinObject(); echo $gtinObject->getType() . PHP_EOL; echo $gtinObject->isValidFormat() . PHP_EOL; echo $gtinObject->isValid() . PHP_EOL;
Output
GTIN-13
true
false