Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

A PHP class for checking EAN8, EAN13, UPC and GTIN barcodes are valid (based on check digit).

License

Notifications You must be signed in to change notification settings

cedcommerce/validator

Open more actions menu
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP Barcode

A PHP class for checking EAN8, EAN13, UPC and GTIN barcodes are valid (based on check digit).

Travis CI Packagist Packagist Packagist Packagist PHP 7 ready

https://packagist.org/packages/cedcommerce/validator

Note: This project currently does nothing other than have some validation functions. I expect to add additional functionality in the future.

Installation (with composer)

composer require cedcommerce/validator

Usage

// 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()

TODO:

  • Barcode generation
  • GS1-128 barcode generation and interpretation

Credits

About

A PHP class for checking EAN8, EAN13, UPC and GTIN barcodes are valid (based on check digit).

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%
Morty Proxy This is a proxified and sanitized view of the page, visit original site.