milindsingh / validator
一组用于管理条形码的PHP类。
2.0.1
2019-03-07 09:32 UTC
Requires
- php: ^5.0 || ^7.0
Requires (Dev)
- phpunit/phpunit: ^4.8
This package is auto-updated.
Last update: 2024-09-22 18:27:26 UTC
README
一个PHP类,用于检查EAN8、EAN13、UPC和GTIN条形码是否有效(基于校验码)。
https://packagist.org.cn/packages/milindsingh/validator
注意:该项目目前只包含一些验证函数。我预计将来会添加更多功能。
安装(使用composer)
composer require milindsingh/validator
用法
// Class instantation $barcode = '5060411950139'; $validator = new \Ced\Validator\Barcode(); $validator->setBarcode($barcode); // Check barcode is in valid format if ($validator->isValid()) { echo 'Valid :)'; } else { echo 'Invalid :('; } // Get the barcode type echo 'Barcode is in format of ' . $validator->getType(); // Possible formats returned are: // (string) "GTIN" which equals constant \Ced\Validator\Barcode::TYPE_GTIN // (string) "EAN-8" which equals constant \Ced\Validator\Barcode::TYPE_EAN_8 // (string) "EAN" which equals constant \Ced\Validator\Barcode::TYPE_EAN // (string) "EAN Restricted" which equals constant \Ced\Validator\Barcode::TYPE_EAN_RESTRICTED // (string) "UPC" which equals constant \Ced\Validator\Barcode::TYPE_UPC // (string) "UPC Coupon Code" which equals constant \Ced\Validator\Barcode::TYPE_UPC_COUPON_CODE // Returns the barcode in GTIN-14 format $validator->getGTIN14() // Returns the barcode as entered $validator->getBarcode()
待办事项
- 条形码生成
- GS1-128条形码生成和解释
致谢
- 原始包由 Luke Cousins 创建。
- 条形码验证函数基于 Ferry Bouwhuis 的工作。
- 从 hassel-it/php-barcodes 分支添加了EAN受限格式。
- 初始单元测试基于 hassel-it/php-barcodes 分支的工作。