Skip to content

Commit

Permalink
v1.1 auto commit (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
pablorsk authored Jun 21, 2021
1 parent 0de14ae commit 9d50ff4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.1.1] - 2021-06-21

### Fixed
- Checksum calculation on Mexico Bank Accounts.

## [1.1.0] - 2021-06-04

### Added
Expand Down
12 changes: 5 additions & 7 deletions src/Mx/MxBankAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
use BankAccounts\BankAccountInterface;

/**
* @author Pablo Gabriel Reyes
*
* @see https://pabloreyes.com.ar/ Blog
* @see https://bank.codes/mexico-clabe-checker/
*/
class MxBankAccount extends BankAccount implements BankAccountInterface
{
Expand Down Expand Up @@ -47,6 +45,7 @@ public function isValid(): bool
}

$controlDigit = $MODULE_TEN - ($accumulator % $MODULE_TEN);
$controlDigit = $controlDigit === 10 ? 0 : $controlDigit;

return end($clabeChars) === (string) $controlDigit;
}
Expand All @@ -65,11 +64,10 @@ public function getBankName(): ?string

public function getInternalBankAccountNumber(): ?string
{
switch ($this->getBankId()) {
case '072': // banorte
return substr($this->getBankAccountNumber(), 7, 10);
if (strlen($this->getBankAccountNumber()) < (17)) {
return null;
}

return null;
return substr($this->getBankAccountNumber(), 6, 11);
}
}
5 changes: 3 additions & 2 deletions tests/Mx/MxBankAccountTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ final class MxBankAccountTest extends TestCase
{
public function testIsValid()
{
static::assertTrue((new MxBankAccount('072580010990912720'))->isValid());
static::assertFalse((new MxBankAccount(''))->isValid());
static::assertFalse((new MxBankAccount('1231243457656434324325'))->isValid());
static::assertFalse((new MxBankAccount('123124345765643432'))->isValid());
Expand All @@ -40,7 +41,7 @@ public function testBankName()

public function testGetInternalBankAccountNumber()
{
static::assertSame('1031285017', (new MxBankAccount('072580010312850172'))->getInternalBankAccountNumber());
static::assertNull((new MxBankAccount('032180000118359719'))->getInternalBankAccountNumber());
static::assertSame('01031285017', (new MxBankAccount('072580010312850172'))->getInternalBankAccountNumber());
static::assertNull((new MxBankAccount('123'))->getInternalBankAccountNumber());
}
}

0 comments on commit 9d50ff4

Please sign in to comment.