Skip to content
This repository was archived by the owner on May 24, 2024. It is now read-only.

Commit 685c49b

Browse files
committed
Followup to 5df7c2e, stop loading subdivisions in the ZoneRepository.
1 parent d6a00e8 commit 685c49b

File tree

2 files changed

+5
-28
lines changed

2 files changed

+5
-28
lines changed

src/Repository/ZoneRepository.php

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,6 @@ class ZoneRepository implements ZoneRepositoryInterface
2121
*/
2222
protected $definitionPath;
2323

24-
/**
25-
* The subdivision repository.
26-
*
27-
* @var SubdivisionRepositoryInterface
28-
*/
29-
protected $subdivisionRepository;
30-
3124
/**
3225
* Zone index.
3326
*
@@ -45,13 +38,11 @@ class ZoneRepository implements ZoneRepositoryInterface
4538
/**
4639
* Creates a ZoneRepository instance.
4740
*
48-
* @param string $definitionPath Path to the zone definitions.
49-
* @param SubdivisionRepositoryInterface $subdivisionRepository The subdivision repository.
41+
* @param string $definitionPath Path to the zone definitions.
5042
*/
51-
public function __construct($definitionPath, SubdivisionRepositoryInterface $subdivisionRepository = null)
43+
public function __construct($definitionPath)
5244
{
5345
$this->definitionPath = $definitionPath;
54-
$this->subdivisionRepository = $subdivisionRepository ?: new SubdivisionRepository();
5546
}
5647

5748
/**
@@ -164,17 +155,6 @@ protected function createZoneFromDefinition(array $definition)
164155
*/
165156
protected function createZoneMemberCountryFromDefinition(array $definition)
166157
{
167-
// Load any referenced subdivisions.
168-
if (isset($definition['administrative_area'])) {
169-
$definition['administrative_area'] = $this->subdivisionRepository->get($definition['administrative_area']);
170-
}
171-
if (isset($definition['locality'])) {
172-
$definition['locality'] = $this->subdivisionRepository->get($definition['locality']);
173-
}
174-
if (isset($definition['dependent_locality'])) {
175-
$definition['dependent_locality'] = $this->subdivisionRepository->get($definition['dependent_locality']);
176-
}
177-
178158
$zoneMember = new ZoneMemberCountry();
179159
$setValues = \Closure::bind(function ($definition) {
180160
$this->id = $definition['id'];

tests/Repository/ZoneRepositoryTest.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,9 @@ public function testGet($zoneRepository)
120120
$this->assertEquals('AT', $austriaMember->getCountryCode());
121121
$this->assertEquals('6691, 6991:6993', $austriaMember->getIncludedPostalCodes());
122122
$this->assertEquals('123456', $austriaMember->getExcludedPostalCodes());
123-
// Test the dummy subdivision values.
124-
$subdivisionRepository = new SubdivisionRepository();
125-
$subdivision = $subdivisionRepository->get('CH-AG');
126-
$this->assertEquals($subdivision, $austriaMember->getAdministrativeArea());
127-
$this->assertEquals($subdivision, $austriaMember->getLocality());
128-
$this->assertEquals($subdivision, $austriaMember->getDependentLocality());
123+
$this->assertEquals('CH-AG', $austriaMember->getAdministrativeArea());
124+
$this->assertEquals('CH-AG', $austriaMember->getLocality());
125+
$this->assertEquals('CH-AG', $austriaMember->getDependentLocality());
129126

130127
// Test the static cache.
131128
$sameZone = $zoneRepository->get('de_vat');

0 commit comments

Comments
 (0)