Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Removed domain `gmail.com.au` from `Provider\en_AU\Internet` (#886)
- Refreshed ISO currencies (#919)
- Improved italian phone number formats
- Fixed BIC generation for `Provider\Payment`

## [2024-11-09, v1.24.0](https://github.com/FakerPHP/Faker/compare/v1.23.1..v1.24.0)

Expand Down
5 changes: 3 additions & 2 deletions src/Faker/Provider/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,12 @@ public static function iban($countryCode = null, $prefix = '', $length = null)
* @example 'RZTIAT22263'
*
* @see http://en.wikipedia.org/wiki/ISO_9362
* @see http://www.iso20022.org
*
* @return string Swift/Bic number
*/
public static function swiftBicNumber()
public static function swiftBicNumber(): string
{
return self::regexify('^([A-Z]){4}([A-Z]){2}([0-9A-Z]){2}([0-9A-Z]{3})?$');
return self::regexify('^([A-Z]{6,6}[A-Z2-9][A-NP-Z0-9][A-Z0-9]{3,3}){0,1}$');
}
}
8 changes: 8 additions & 0 deletions test/Faker/Provider/PaymentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,14 @@ public function testIban($countryCode, $regex): void
self::assertTrue(Iban::isValid($iban), "Checksum for $iban is invalid");
}

public function testSwitchBicNumber(): void
{
$bic = $this->faker->swiftBicNumber();

// Test format
self::assertMatchesRegularExpression('~^[A-Z]{6,6}[A-Z2-9][A-NP-Z0-9]([A-Z0-9]{3,3}){0,1}$~', $bic, "Bic for $bic is invalid");
}

protected function getProviders(): iterable
{
yield new BaseProvider($this->faker);
Expand Down