ekman / luhn-algorithm Goto Github PK
View Code? Open in Web Editor NEWMinimal, zero-dependency implementation of the Luhn Algorithm for PHP.
License: MIT License
Minimal, zero-dependency implementation of the Luhn Algorithm for PHP.
License: MIT License
Update the compatible PHP version to the highest (still maintained) PHP version.
Include changes such as:
nullable
return typesThe following number is valid (successfully tested with other libraries) but it is detected as invalid by this class : 31997233700020
There is a small typo in a method name.
LuhnAlgorithm::calculcateCheckDigit();
Add @throws LuhmAlgorithmExceptionInterface to all methods in facade. I don't want to do it without making a major version update due to it theoretically is a backward incompatible change.
This implementation assumes that that the "number" is an integer when it should be a string of [0-9].
Consider SIM card ICCID numbers which are greater than PHP_INT_MAX 64bit.
public function testOne(): void
{
$luhn = new LuhnAlgorithm();
$this->assertTrue($luhn->isValid(Number::fromString('89148000003974165685')));
}
Failed asserting that false is true.
public function testTwo(): void
{
$number = Number::fromString($input = '89148000003974165685');
$this->assertEquals($input, $number->getNumber());
}
Failed asserting that 922337203685477632 matches expected '89148000003974165685'.
The use of intval in stringToInteger() limits the number that can be used to the maximum signed integer range of -2147483648 to 2147483647
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.