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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@
/vendor-bin/rector/vendor/
/.php-cs-fixer.cache
/composer.lock

.idea
74 changes: 67 additions & 7 deletions src/Provider/he_IL/PhoneNumber.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,71 @@

class PhoneNumber extends \Faker\Provider\PhoneNumber
{
protected static $formats = [
'05#-#######',
'0#-#######',
'972-5#-#######',
'972-#-########',
'0#########',
];
protected static $mobileFormat = '05#-#######';
protected static $landlineFormat = '0#-#######';
protected static $internationalMobileFormat = '972-5#-#######';
protected static $internationalLandlineFormat = '972-#-########';
protected static $clearMobileFormat = '05########';

public static function phoneNumber()
{
return static::numerify(static::randomElement([
static::$mobileFormat,
static::$landlineFormat,
static::$internationalMobileFormat,
static::$internationalLandlineFormat,
static::$clearMobileFormat,
]));
}

public static function mobileNumber()
{
return static::numerify(static::$mobileFormat);
}

public static function cellularNumber()
{
return static::mobileNumber();
}

public static function mobilePhoneNumber()
{
return static::mobileNumber();
}

public static function landlineNumber()
{
return static::numerify(static::$landlineFormat);
}

public static function internationalMobileNumber()
{
return static::numerify(static::$internationalMobileFormat);
}

public static function internationalCelnumber()
{
return static::internationalMobileNumber();
}

public static function internationalLandline()
{
return static::numerify(static::$internationalLandlineFormat);
}

public static function clearMobileNumber()
{
return static::numerify(static::$clearMobileFormat);

}

public static function clearMobilePhoneNumber()
{
return static::clearMobileNumber();
}

public static function clearCellularPhoneNumber()
{
return static::clearMobileNumber();
}
}
45 changes: 45 additions & 0 deletions test/Provider/he_IL/PhoneNumberTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

namespace Faker\Test\Provider\he_IL;

use Faker\Provider\he_IL\PhoneNumber;
use Faker\Test\TestCase;

final class PhoneNumberTest extends TestCase
{
public function testMobileNumber()
{
$provider = new PhoneNumber($this->faker);
$this->assertMatchesRegularExpression('/^05\d-\d{7}$/', $provider->mobileNumber());
}

public function testLandlineNumber()
{
$provider = new PhoneNumber($this->faker);
$this->assertMatchesRegularExpression('/^0\d-\d{7}$/', $provider->landlineNumber());
}

public function testInternationalMobileNumber()
{
$provider = new PhoneNumber($this->faker);
$this->assertMatchesRegularExpression('/^972-5\d-\d{7}$/', $provider->internationalMobileNumber());
}

public function testInternationalLandline()
{
$provider = new PhoneNumber($this->faker);
$this->assertMatchesRegularExpression('/^972-\d-\d{8}$/', $provider->internationalLandline());
}

public function testClearMobilePhoneNumber()
{
$provider = new PhoneNumber($this->faker);
$this->assertMatchesRegularExpression('/^05\d{8}$/', $provider->clearMobilePhoneNumber());
}

public function testClearMobileNumber()
{
$provider = new PhoneNumber($this->faker);
$this->assertMatchesRegularExpression('/^05\d{8}$/', $provider->clearMobileNumber());
}
}