digitalcz / register-adries
Provides communication with https://data.gov.sk/dataset/register-adries in PHP OOP via PSR-18 HTTP client
Installs: 12 869
Dependents: 0
Suggesters: 0
Security: 0
Stars: 5
Watchers: 2
Forks: 1
Open Issues: 4
Requires
- php: ~7.4||~8.0
- ext-json: *
- php-http/discovery: ^1.7
- psr/http-client: ^1.0
- psr/http-message: ^1.0.1
Requires (Dev)
- dealerdirect/phpcodesniffer-composer-installer: ^0.7.0
- digitalcz/coding-standard: ^v0.0.1
- nyholm/psr7: ^1.5.1
- php-http/httplug: ^2.3.0
- php-http/mock-client: ^1.5.0
- phpstan/phpstan: ^1.9.2
- phpunit/phpunit: ^8.5.31
- squizlabs/php_codesniffer: ^3.7.1
- symfony/var-dumper: ^5.4.14
Suggests
- v1.2.0
- v1.1.0
- dev-master / 1.0.x-dev
- v1.0.0
- v0.2.0
- v0.1.1
- v0.1.0
- dev-dependabot/composer/phpunit/phpunit-tw-8.5.31or-tw-9.0.0
- dev-php-8
- dev-dependabot/github_actions/actions/cache-3.0.11
- dev-dependabot/github_actions/actions/checkout-3.1.0
- dev-dependabot/github_actions/codecov/codecov-action-3.1.1
- dev-spajxo/conditions-improvements
This package is auto-updated.
Last update: 2024-12-08 01:14:19 UTC
README
Provides communication with https://data.gov.sk/dataset/register-adries in PHP OOP via PSR-18 HTTP client
Install
Via Composer
$ composer require digitalcz/register-adries
Usage
$register = new DigitalCz\RegisterAdries\RegisterAdries(); $response = $register ->request() // create RequestBuilder ->regions() // set resource to fetch ->limit(5) // limit number of results ->offset(10) // offset first result ->execute(); // execute the request and return response $response->getRecords(); // DigitalCz\RegisterAdries\Response\Region[] $response->getTotal(); // total number of results
With conditions
$register = new DigitalCz\RegisterAdries\RegisterAdries(); $register ->request() // create RequestBuilder // comparison ->whereEq('foo', 'bar') // `foo = bar` ->whereNeq('foo', 'bar') // `foo != bar` ->whereGt('foo', 40) // `foo > 40` ->whereGte('foo', 40) // `foo >= 40` ->whereLt('foo', 40) // `foo < 40` ->whereLte('foo', 40) // `foo <= 40` // like ->whereLike('foo', 'bar') // `foo LIKE bar` ->whereStartsWith('foo', 'bar') // `foo LIKE bar%` ->whereEndsWith('foo', 'bar') // `foo LIKE %bar` ->whereContains('foo', 'bar') // `foo LIKE %bar%` // helpers ->whereObjectId(12) // `objectId = 12` ->onlyValid(); // `WHERE {now} > validFrom AND {now} < validTo`
Requesting by objectId
$register = new DigitalCz\RegisterAdries\RegisterAdries(); $register->findRegion(9); // returns DigitalCz\RegisterAdries\Response\Region or null $register->findCounty(9); // returns DigitalCz\RegisterAdries\Response\County or null $register->findMunicipality(9); // returns DigitalCz\RegisterAdries\Response\Municipality or null $register->findDistrict(9); // returns DigitalCz\RegisterAdries\Response\District or null $register->findStreet(9); // returns DigitalCz\RegisterAdries\Response\Street or null $register->findUnit(9); // returns DigitalCz\RegisterAdries\Response\Unit or null $register->findBuilding(9); // returns DigitalCz\RegisterAdries\Response\Building or null $register->findEntrance(9); // returns DigitalCz\RegisterAdries\Response\Entrance or null
Available resources
- region - https://data.gov.sk/dataset/register-adries-register-krajov
- county - https://data.gov.sk/dataset/register-adries-register-okresov
- municipality - https://data.gov.sk/dataset/register-adries-register-obci
- district - https://data.gov.sk/dataset/register-adries-register-casti-obci
- street - https://data.gov.sk/dataset/register-adries-register-ulic
- unit - https://data.gov.sk/dataset/register-adries-register-bytov
- building - https://data.gov.sk/dataset/register-adries-register-budov
- entrance - https://data.gov.sk/dataset/register-adries-register-vchodov
Available on builder as
$register = new DigitalCz\RegisterAdries\RegisterAdries(); $register ->request() // ... ->resource('region') ->resource(DigitalCz\RegisterAdries\RegisterResource::REGION) ->regions() // ... ->counties() ->municipalities() ->districts() ->streets() ->units() ->buildings() ->entrances(); // It isn't possible to request more resources, this is just example
Using your own http client
You can provide PSR18 http client (and PSR17 factories) when creating instance of RegisterAdries, if no arguments are provided Psr18ClientDiscovery and Psr17FactoryDiscovery will be used (see https://php-http.readthedocs.io/en/latest/discovery.html).
// example $symfonyHttpClient = Symfony\Component\HttpClient\Psr18Client(); $register = new DigitalCz\RegisterAdries\RegisterAdries( $symfonyHttpClient, $symfonyHttpClient // symfony PSR18 client is also PSR17 factory );
Change log
Please see CHANGELOG for more information on what has changed recently.
Testing
$ composer checks # codesniffer + phpstan + phpunit $ composer csfix # code beautifier
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email devs@digital.cz instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.