Repository navigation
feat: add sunrise/sunset, stations() and nearestStation() - #50
Merged
Merged
Conversation
Allow Pest 3.8/4/5 so every supported PHP version resolves, drop the always-on coverage and junit reports from phpunit.xml.dist, add PHP 8.5 to the matrices and run Tests and PHPStan on pull requests (push only on main).
…possible raintext times
…t/sun-stations-nearest
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #50 +/- ##
============================================
- Coverage 92.85% 87.14% -5.72%
- Complexity 40 64 +24
============================================
Files 4 4
Lines 168 210 +42
============================================
+ Hits 156 183 +27
- Misses 12 27 +15 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Exposes data the JSON feed already contains but the package didn't return.
sunrise(): ?DateTimeImmutableandsunset(): ?DateTimeImmutable: parseactual.sunrise/actual.sunset(local time without offset) inEurope/Amsterdam. Returnnullwhen the value is missing, isn't a string, or isn't exactlyY-m-d\TH:i:s. Partial dates, offsets and rolled-over dates like02-30are rejected.stations(): array<int, ActualForecast>: every current station measurement, list-indexed.nearestStation(float $lat, float $lon): ?ActualForecast: nearest station by haversine great-circle distance. A measurement without numericlat/lonin the raw feed is skipped, becauseActualForecast::fromArraywould otherwise default it to0.0, 0.0. Returnsnullwhen no station has coordinates.actualForecastForStation()does. Callingsunrise()andsunset()(orstations()andnearestStation()) therefore downloads the feed twice until Every call re-downloads the whole feed #42 adds per-instance caching.Usage
nearestStation(),sunrise()andsunset()as returningnullon failure; failure-path tests (non-2xx, malformedactual/stationmeasurements) for all four new methods.Tests
28 tests / 57 assertions pass (14 new in
tests/StationsTest.php), PHPStan clean.nullwhen the feed has no sun times (the fixture has none) and for malformed values: date only, no seconds, with offset, impossible date, non-string, empty.stations()against the fixture returns 3ActualForecasts with list keys.nearestStation(52.1, 5.18)against the fixture returns De Bilt, and a point near Volkel returns Volkel.nullis returned when no station has both coordinates.[]fromstations()andnullfrom the other methods.Also checked against the live feed: 40 stations, sunrise
2026-11-13T07:55:00+01:00.Closes #43