tiendanube / gtinvalidation
Validates GTIN product codes.
Installs: 2 791 221
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 10
Forks: 0
Open Issues: 0
Requires
- php: >=5.4
Requires (Dev)
- phpunit/phpunit: 4.6.*
This package is not auto-updated.
Last update: 2024-11-16 10:49:51 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