forked from fzaninotto/Faker
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Swedish mobileNumber() * Add format reference * php-cs-fixer * Update src/Faker/Provider/sv_SE/PhoneNumber.php Co-authored-by: Andreas Möller <am@localheinz.com> * Update src/Faker/Provider/sv_SE/PhoneNumber.php Co-authored-by: Andreas Möller <am@localheinz.com> * Update src/Faker/Provider/sv_SE/PhoneNumber.php Co-authored-by: Andreas Möller <am@localheinz.com> * Update src/Faker/Provider/sv_SE/PhoneNumber.php Co-authored-by: Andreas Möller <am@localheinz.com> * Create sv_SE MobileNumber test * added more patterns and fixed test * str_starts_with php 7.4 Co-authored-by: Andreas Möller <am@localheinz.com>
- Loading branch information
1 parent
ffcf9b7
commit c8461d9
Showing
2 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace Faker\Test\Provider\sv_SE; | ||
|
||
use Faker\Provider\sv_SE\PhoneNumber; | ||
use Faker\Test\TestCase; | ||
|
||
/** | ||
* @group legacy | ||
*/ | ||
final class PhoneNumberTest extends TestCase | ||
{ | ||
public function testMobileNumber(): void | ||
{ | ||
for ($i = 0; $i < 10; ++$i) { | ||
$number = $this->faker->mobileNumber; | ||
|
||
self::assertTrue(self::itStartsWithPrefix($number)); | ||
} | ||
} | ||
|
||
protected static function itStartsWithPrefix($number): bool | ||
{ | ||
$prefixes = ['+467', '+46(0)7', '+46 (0)7', '+46 (0)7', '07']; | ||
|
||
foreach ($prefixes as $prefix) { | ||
if (strpos($number, (string) $prefix) === 0) { | ||
return true; | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
|
||
protected function getProviders(): iterable | ||
{ | ||
yield new PhoneNumber($this->faker); | ||
} | ||
} |