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