traewelling / db-rest-mappings
This package provides a simple data structure for the REST responses of https://v5.db.transport.rest/.
dev-main
2025-01-08 15:05 UTC
Requires
- php: ^8.0
- ext-json: *
Requires (Dev)
- phpunit/phpunit: ^11.5
This package is auto-updated.
Last update: 2025-03-08 15:40:59 UTC
README
This package is a very simple implementation of the datatypes used in https://v5.db.transport.rest/ and the corresponding API.
Warning
This is in very early development. Code might change without notice in the same version. Use at your own risk.
Usage
// get your departure board $responseJson = $client->get('/stops/8000191/departures', $query); $data = json_decode($responseJson, true); // parse into a DepartureBoard $hydrator = new \DRM\Hydrator\DbRestHydrator(); foreach ($data as $key => $value) { $data[$key] = $hydrator->hydrate($value, \DRM\Dto\Departure::class); }