isValid() public static method

Checks whether a number (partial number + check digit) is Luhn compliant
public static isValid ( string $number ) : boolean
$number string
return boolean
 public function testSirenReturnsAWellFormattedSiren()
 {
     $siren = $this->faker->siren();
     $this->assertRegExp("/^\\d{3}\\s\\d{3}\\s\\d{3}\$/", $siren);
     $siren = str_replace(' ', '', $siren);
     $this->assertTrue(Luhn::isValid($siren));
 }
 public function testImeiReturnsValidNumber()
 {
     $imei = $this->faker->imei();
     $this->assertTrue(Luhn::isValid($imei));
 }
 public function testPersonalIdentityNumberGeneratesLuhnCompliantNumbers()
 {
     $pin = str_replace('-', '', $this->faker->personalIdentityNumber());
     $this->assertTrue(Luhn::isValid($pin));
 }
Beispiel #4
0
 /**
  * @dataProvider validatorProvider
  */
 public function testIsValid($number, $isValid)
 {
     $this->assertEquals($isValid, Luhn::isValid($number));
 }
 /**
  * @dataProvider creditCardNumberProvider
  */
 public function testCreditCardNumberReturnsValidCreditCardNumber($type, $regexp)
 {
     $cardNumber = $this->faker->creditCardNumber($type);
     $this->assertRegExp($regexp, $cardNumber);
     $this->assertTrue(Luhn::isValid($cardNumber));
 }