Address.php
5 years ago
Company.php
5 years ago
Payment.php
5 years ago
Person.php
5 years ago
PhoneNumber.php
5 years ago
Text.php
5 years ago
Payment.php
38 lines
| 1 | <?php |
| 2 | |
| 3 | |
| 4 | namespace Faker\Provider\en_US; |
| 5 | |
| 6 | class Payment extends \Faker\Provider\Payment |
| 7 | { |
| 8 | public function bankAccountNumber() |
| 9 | { |
| 10 | // Length between 5 and 17, biased towards center |
| 11 | $length = self::numberBetween(0, 3) + self::numberBetween(0, 3) + self::numberBetween(0, 3) + self::numberBetween(0, 3) + 5; |
| 12 | |
| 13 | return self::numerify(str_repeat('#', $length)); |
| 14 | } |
| 15 | |
| 16 | public function bankRoutingNumber() |
| 17 | { |
| 18 | $district = self::numberBetween(1, 12); |
| 19 | $type = self::randomElement(array(0, 0, 0, 0, 20, 20, 60)); |
| 20 | $clearingCenter = self::randomDigitNotNull(); |
| 21 | $state = self::randomDigit(); |
| 22 | $institution = self::randomNumber(4, true); |
| 23 | |
| 24 | $result = sprintf('%02d%01d%01d%04d', $district + $type, $clearingCenter, $state, $institution); |
| 25 | |
| 26 | return $result . self::calculateRoutingNumberChecksum($result); |
| 27 | } |
| 28 | |
| 29 | public static function calculateRoutingNumberChecksum($routing) |
| 30 | { |
| 31 | return ( |
| 32 | 7 * ($routing[0] + $routing[3] + $routing[6]) + |
| 33 | 3 * ($routing[1] + $routing[4] + $routing[7]) + |
| 34 | 9 * ($routing[2] + $routing[5]) |
| 35 | ) % 10; |
| 36 | } |
| 37 | } |
| 38 |