Skip to content

Commit

Permalink
Merge pull request #2 from damien-louis/feature/rename-class
Browse files Browse the repository at this point in the history
Rename class
  • Loading branch information
damien-louis authored Dec 10, 2023
2 parents 9fa37b3 + e532a4e commit d5d9221
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use libphonenumber\PhoneNumberUtil;

class PhoneNumberOneLine
class PhoneNumberShortcuts
{
public const E164 = 0;
public const INTERNATIONAL = 1;
Expand Down
14 changes: 7 additions & 7 deletions tests/FormatTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,34 @@
use PHPUnit\Framework\TestCase;

/**
* @covers \PhoneNumberOneLine
* @covers \PhoneNumberShortcuts
*/
class FormatTest extends TestCase
{
public static function testException(): void
{
$result = \PhoneNumberOneLine::format('itsnotanumber', PhoneNumberOneLine::E164, 'FR');
$result = \PhoneNumberShortcuts::format('itsnotanumber', PhoneNumberShortcuts::E164, 'FR');
self::assertNull($result);
}

public static function testFormatWithRegion(): void
{
$result = \PhoneNumberOneLine::format('0605040302', PhoneNumberOneLine::E164, 'FR');
$result = \PhoneNumberShortcuts::format('0605040302', PhoneNumberShortcuts::E164, 'FR');
self::assertSame($result, '+33605040302');

$result = \PhoneNumberOneLine::format('0605040302', PhoneNumberOneLine::NATIONAL, 'FR');
$result = \PhoneNumberShortcuts::format('0605040302', PhoneNumberShortcuts::NATIONAL, 'FR');
self::assertSame($result, '06 05 04 03 02');

$result = \PhoneNumberOneLine::format('0605040302', PhoneNumberOneLine::INTERNATIONAL, 'FR');
$result = \PhoneNumberShortcuts::format('0605040302', PhoneNumberShortcuts::INTERNATIONAL, 'FR');
self::assertSame($result, '+33 6 05 04 03 02');

$result = \PhoneNumberOneLine::format('0605040302', PhoneNumberOneLine::RFC3966, 'FR');
$result = \PhoneNumberShortcuts::format('0605040302', PhoneNumberShortcuts::RFC3966, 'FR');
self::assertSame($result, 'tel:+33-6-05-04-03-02');
}

public static function testFormatWithoutRegion(): void
{
$result = \PhoneNumberOneLine::format('+33605040302', PhoneNumberOneLine::NATIONAL);
$result = \PhoneNumberShortcuts::format('+33605040302', PhoneNumberShortcuts::NATIONAL);
self::assertSame($result, '06 05 04 03 02');
}
}
10 changes: 5 additions & 5 deletions tests/RegionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@
use PHPUnit\Framework\TestCase;

/**
* @covers \PhoneNumberOneLine
* @covers \PhoneNumberShortcuts
*/
class RegionTest extends TestCase
{
public static function testRegion(): void
{
$result = \PhoneNumberOneLine::getRegionCodeForNumber('+44 117 496 0123');
$result = \PhoneNumberShortcuts::getRegionCodeForNumber('+44 117 496 0123');
self::assertSame($result, 'GB');

$result = \PhoneNumberOneLine::getRegionCodeForNumber('+33 1 02 03 04 05');
$result = \PhoneNumberShortcuts::getRegionCodeForNumber('+33 1 02 03 04 05');
self::assertSame($result, 'FR');

$result = \PhoneNumberOneLine::getRegionCodeForNumber('+12135096995');
$result = \PhoneNumberShortcuts::getRegionCodeForNumber('+12135096995');
self::assertSame($result, 'US');

$result = \PhoneNumberOneLine::getRegionCodeForNumber('notanumber');
$result = \PhoneNumberShortcuts::getRegionCodeForNumber('notanumber');
self::assertNull($result);
}
}
16 changes: 8 additions & 8 deletions tests/ValidTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,34 @@
use PHPUnit\Framework\TestCase;

/**
* @covers \PhoneNumberOneLine
* @covers \PhoneNumberShortcuts
*/
class ValidTest extends TestCase
{
public static function testValidWithRegion(): void
{
$isValid = \PhoneNumberOneLine::isValid('06 07 08 09 10', 'FR');
$isValid = \PhoneNumberShortcuts::isValid('06 07 08 09 10', 'FR');
self::assertTrue($isValid);

$isValid = \PhoneNumberOneLine::isValid('0607080910', 'FR');
$isValid = \PhoneNumberShortcuts::isValid('0607080910', 'FR');
self::assertTrue($isValid);

$isValid = \PhoneNumberOneLine::isValid('+33 607080910', 'FR');
$isValid = \PhoneNumberShortcuts::isValid('+33 607080910', 'FR');
self::assertTrue($isValid);

$isValid = \PhoneNumberOneLine::isValid('+1607080910', 'FR');
$isValid = \PhoneNumberShortcuts::isValid('+1607080910', 'FR');
self::assertFalse($isValid);

$isValid = \PhoneNumberOneLine::isValid('+44123', 'FR');
$isValid = \PhoneNumberShortcuts::isValid('+44123', 'FR');
self::assertFalse($isValid);
}

public static function testValidWithoutRegion(): void
{
$isValid = \PhoneNumberOneLine::isValid('+33 607080910');
$isValid = \PhoneNumberShortcuts::isValid('+33 607080910');
self::assertTrue($isValid);

$isValid = \PhoneNumberOneLine::isValid('notanumber');
$isValid = \PhoneNumberShortcuts::isValid('notanumber');
self::assertFalse($isValid);
}
}

0 comments on commit d5d9221

Please sign in to comment.