Skip to content
Merged
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
28 changes: 23 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ Register for free at [nederlandpostcode.nl](https://nederlandpostcode.nl) to obt

| Version | Release |
|---------|---------|
| 13.x | ^1.3 |
| 12.x | ^1.3 |
| 13.x | ^1.5 |
| 12.x | ^1.5 |

## Installation

Expand Down Expand Up @@ -66,6 +66,7 @@ The following optional attributes can be requested to be included in the respons

- `coordinates`: Includes latitude and longitude of the address.
- `district`: Includes the official and name of the district that the address belongs to.
- `neighborhood`: Includes the official name of the neighborhood that the address belongs to.
- `function`: Includes the function of the address (e.g. residential, commercial, healthcare, etc.).
- `location_status`: Includes the location status of the address (e.g. active, in development, etc.).
- `property_status`: Includes the property status of the address (e.g. in use, under construction, etc.).
Expand Down Expand Up @@ -204,14 +205,31 @@ EnergyLabelCollection {
addition: null,
street: "Schiphol Boulevard",
city: "Schiphol",
registrationDate: DateTime("2022-08-30"),
inspectionDate: DateTime("2022-08-02"),
validUntilDate: DateTime("2032-08-02"),
constructionType: "utiliteitsbouw",
buildingType: null,
energyLabel: "A+++",
maxEnergyDemand: 98.4,
maxFossilEnergyDemand: 55.48,
minRenewableShare: 55.3
calculationType: "NTA 8800:2022 (basisopname utiliteitsbouw)",
inspectionType: "basis",
status: "bestaand",
constructionYear: 2019,
usageAreaThermalZone: 5648.39,
compactness: 1.16,
energyDemand: 98.4,
energyDemandRequirement: null,
primaryFossilEnergy: 55.48,
primaryFossilEnergyRequirement: null,
primaryFossilEnergyEmg: null,
renewableShare: 55.3,
renewableShareRequirement: null,
renewableShareEmg: null,
calculatedEnergyConsumption: 55.48,
heatDemand: 55.02,
calculatedCo2Emission: 13.01,
temperatureExcess: 0,
temperatureExcessRequirement: null
}, {
...
}
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
}
],
"require": {
"label84/php-nederland-postcode": "^1.3"
"label84/php-nederland-postcode": "^2.0"
},
"require-dev": {
"laravel/pint": "^1.29",
Expand Down
33 changes: 33 additions & 0 deletions tests/Resources/AddressResourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,25 @@ public function test_get_single_result(): void

$this->assertInstanceOf(AddressCollection::class, $result);
$this->assertCount(1, $result);

$address = $result->all()[0];
$this->assertSame('1118BN', $address->postcode);
$this->assertSame(800, $address->number);
$this->assertSame('', $address->addition);
$this->assertSame('Schiphol Boulevard', $address->street);
$this->assertSame('Schiphol', $address->city);
$this->assertSame('Haarlemmermeer', $address->municipality);
$this->assertSame('Noord-Holland', $address->province);
$this->assertSame('Nederland', $address->country);
$this->assertSame(52.30528553688755, $address->coordinates->latitude);
$this->assertSame(4.750645160863609, $address->coordinates->longitude);
$this->assertNull($address->neighborhood);
$this->assertNull($address->district);
$this->assertNull($address->function);
$this->assertNull($address->location_status);
$this->assertNull($address->property_status);
$this->assertNull($address->surface_area);
$this->assertNull($address->construction_year);
}

public function test_get_multiple_results(): void
Expand All @@ -34,5 +53,19 @@ public function test_get_multiple_results(): void

$this->assertInstanceOf(AddressCollection::class, $result);
$this->assertCount(4, $result);

$additions = array_map(fn ($address) => $address->addition, $result->all());
$this->assertSame(['A', 'B', 'C', 'D'], $additions);

$first = $result->all()[0];
$this->assertSame('1015CN', $first->postcode);
$this->assertSame(10, $first->number);
$this->assertSame('Keizersgracht', $first->street);
$this->assertSame('Amsterdam', $first->city);
$this->assertSame('Amsterdam', $first->municipality);
$this->assertSame('Noord-Holland', $first->province);
$this->assertSame('Nederland', $first->country);
$this->assertSame(52.379401496779124, $first->coordinates->latitude);
$this->assertSame(4.889216673725493, $first->coordinates->longitude);
}
}
72 changes: 67 additions & 5 deletions tests/Resources/EnergyLabelResourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,88 @@ public function test_single_energy_label(): void
$result = app(NederlandPostcodeClient::class)
->energyLabels()
->get(
postcode: '1118BN',
number: 800,
postcode: '5465SM',
number: 7,
addition: null,
);

$this->assertInstanceOf(EnergyLabelCollection::class, $result);
$this->assertCount(1, $result);

$label = $result->all()[0];
$this->assertSame('5465SM', $label->postcode);
$this->assertSame(7, $label->number);
$this->assertNull($label->addition);
$this->assertSame('Klaverhoeve', $label->street);
$this->assertSame('Veghel', $label->city);
$this->assertSame('31-08-2026', $label->registrationDate->format('d-m-Y'));
$this->assertSame('31-08-2026', $label->inspectionDate->format('d-m-Y'));
$this->assertSame('31-08-2036', $label->validUntilDate->format('d-m-Y'));
$this->assertSame('woningbouw', $label->constructionType);
$this->assertSame('twee-onder-één-kap', $label->buildingType);
$this->assertSame('A++++', $label->energyLabel);
$this->assertSame('NTA 8800:2025 (detailopname woningbouw)', $label->calculationType);
$this->assertSame('detail', $label->inspectionType);
$this->assertSame('oplevering', $label->status);
$this->assertSame(2025, $label->constructionYear);
$this->assertSame(130.89, $label->usageAreaThermalZone);
$this->assertSame(2.31, $label->compactness);
$this->assertSame(76.54, $label->energyDemand);
$this->assertSame(79.38, $label->energyDemandRequirement);
$this->assertSame(-7.02, $label->primaryFossilEnergy);
$this->assertSame(30.0, $label->primaryFossilEnergyRequirement);
$this->assertNull($label->primaryFossilEnergyEmg);
$this->assertSame(107.7, $label->renewableShare);
$this->assertSame(50.0, $label->renewableShareRequirement);
$this->assertNull($label->renewableShareEmg);
$this->assertSame(-7.03, $label->calculatedEnergyConsumption);
$this->assertSame(47.59, $label->heatDemand);
$this->assertSame(-1.3, $label->calculatedCo2Emission);
$this->assertSame(0.0, $label->temperatureExcess);
$this->assertSame(1.2, $label->temperatureExcessRequirement);
}

public function test_multiple_energy_labels(): void
{
$result = app(NederlandPostcodeClient::class)
->energyLabels()
->get(
postcode: '1015CN',
number: 10,
postcode: '7316ER',
number: 73,
addition: null,
);

$this->assertInstanceOf(EnergyLabelCollection::class, $result);
$this->assertCount(2, $result);
$this->assertCount(3, $result);

$energyLabels = array_map(fn ($label) => $label->energyLabel, $result->all());
$this->assertSame(['C', 'E', 'G'], $energyLabels);

$first = $result->all()[0];
$this->assertSame('7316ER', $first->postcode);
$this->assertSame(73, $first->number);
$this->assertNull($first->addition);
$this->assertSame('Laan van Kerschoten', $first->street);
$this->assertSame('Apeldoorn', $first->city);
$this->assertSame('09-10-2025', $first->registrationDate->format('d-m-Y'));
$this->assertSame('07-10-2025', $first->inspectionDate->format('d-m-Y'));
$this->assertSame('07-10-2035', $first->validUntilDate->format('d-m-Y'));
$this->assertSame('woningbouw', $first->constructionType);
$this->assertSame('twee-onder-één-kap', $first->buildingType);
$this->assertSame('basis', $first->inspectionType);
$this->assertSame('bestaand', $first->status);
$this->assertSame(1958, $first->constructionYear);
$this->assertSame(177.57, $first->energyDemand);
$this->assertSame(218.86, $first->primaryFossilEnergy);
$this->assertSame(1.24, $first->temperatureExcess);
$this->assertNull($first->temperatureExcessRequirement);

$third = $result->all()[2];
$this->assertSame('utiliteitsbouw', $third->constructionType);
$this->assertNull($third->buildingType);
$this->assertSame('G', $third->energyLabel);
$this->assertSame(580.39, $third->primaryFossilEnergyEmg);
$this->assertSame(3.2, $third->renewableShare);
$this->assertSame(3.2, $third->renewableShareEmg);
}
}
Loading
Loading