metro-markets / gtin-validator
Fork of Real GTIN Validator
Installs: 10 430
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 11
Open Issues: 0
Requires
- php: ^7.1
Requires (Dev)
- php-coveralls/php-coveralls: ^2.1
- phpunit/phpunit: ^7.3 || ^8.0
This package is auto-updated.
Last update: 2025-02-20 20:41:22 UTC
README
A GTIN is a string of digits that uniquely identifies a trade item (a product that is bought and sold). A GTIN is globally unique, meaning that no two products in the world share the same GTIN.
This library provides a straightforward way by which a number can be determined to be a valid GTIN or suspected of being invalid in some way.
Installation
via Composer
$ composer require metro-markets/gtin-validator
via GitHub
$ git clone https://github.com/metro-markets/gtin-validator.git
Usage
<?php use Real\Validator\Gtin; // create a valid GTIN $value = '4006381333931'; $gtin = Gtin\Factory::create($value); // handle errors $value = 'any invalid value'; try { $gtin = Gtin\Factory::create($value); } catch (Gtin\NonNormalizable $e) { // ... }
GTIN interface overview
Each created GTIN implements a common interface. This is a complete list of its methods:
Testing
$ composer test
License
Real GTIN Validator is licensed under The Apache License 2.0. Please see LICENSE for details.
Changelog
Please see CHANGELOG for more information.