ryanblak / gtinvalidation
Validates GTIN product codes.
Installs: 6 711
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: >=5.4
Requires (Dev)
- phpunit/phpunit: 4.6.*
This package is not auto-updated.
Last update: 2018-07-18 15:50:38 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:
composer require ryanblak/gtinvalidation
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