Skip to content

Commit

Permalink
Merge pull request #29 from giggsey/mirror-584
Browse files Browse the repository at this point in the history
Use absolute paths for metadata
  • Loading branch information
giggsey authored Jul 10, 2023
2 parents e773d8b + 8c72e29 commit 40451f1
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ build.xml export-ignore
phpunit.xml.dist export-ignore
infection.json.dist export-ignore
.github/ export-ignore
src/CountryCodeToRegionCodeMapForTesting.php export-ignore

* text=auto
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
"phpstan.neon.dist",
"build.xml",
"phpunit.xml.dist",
"infection.json.dist"
"infection.json.dist",
"src/CountryCodeToRegionCodeMapForTesting.php"
]
},
"require": {
Expand Down
3 changes: 3 additions & 0 deletions src/MultiFileMetadataSourceImpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace libphonenumber;

/**
* @internal
*/
class MultiFileMetadataSourceImpl implements MetadataSourceInterface
{
protected static string $metaDataFilePrefix = PhoneNumberUtil::META_DATA_FILE_PREFIX;
Expand Down
4 changes: 2 additions & 2 deletions src/PhoneNumberUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class PhoneNumberUtil
/**
* @internal
*/
public const META_DATA_FILE_PREFIX = 'PhoneNumberMetadata';
public const META_DATA_FILE_PREFIX = __DIR__ . '/data/PhoneNumberMetadata';

// Region-code for the unknown region.
protected const UNKNOWN_REGION = 'ZZ';
Expand Down Expand Up @@ -407,7 +407,7 @@ public static function getInstance(
}

if ($metadataSource === null) {
$metadataSource = new MultiFileMetadataSourceImpl($metadataLoader, __DIR__ . '/data/' . $baseFileLocation);
$metadataSource = new MultiFileMetadataSourceImpl($metadataLoader, $baseFileLocation);
}

static::$instance = new static($metadataSource, $countryCallingCodeToRegionCodeMap);
Expand Down
6 changes: 1 addition & 5 deletions tests/Issues/UKNumbersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,12 @@

class UKNumbersTest extends TestCase
{
public const META_DATA_FILE_PREFIX = 'PhoneNumberMetadata';
protected PhoneNumberUtil $phoneUtil;

public function setUp(): void
{
PhoneNumberUtil::resetInstance();
$this->phoneUtil = PhoneNumberUtil::getInstance(
self::META_DATA_FILE_PREFIX,
CountryCodeToRegionCodeMap::COUNTRY_CODE_TO_REGION_CODE_MAP
);
$this->phoneUtil = PhoneNumberUtil::getInstance();
}

public function testMobileNumber(): void
Expand Down
2 changes: 1 addition & 1 deletion tests/core/PhoneNumberUtilTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

class PhoneNumberUtilTest extends TestCase
{
public const TEST_META_DATA_FILE_PREFIX = '../../tests/core/data/PhoneNumberMetadataForTesting';
public const TEST_META_DATA_FILE_PREFIX = __DIR__ . '/data/PhoneNumberMetadataForTesting';
private static PhoneNumber $bsNumber;
private static PhoneNumber $coFixedLine;
private static PhoneNumber $internationalTollFree;
Expand Down

0 comments on commit 40451f1

Please sign in to comment.