koren-software / ehak-locations
PHP Library to convert location into EHAK classification code and vice-versa
Installs: 3 493
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 1
Open Issues: 0
Requires
- php: >=7.4
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.16
- php-coveralls/php-coveralls: ^2.1
- phpunit/phpunit: ^9.4
- shuchkin/simplexlsx: ^1.0
- squizlabs/php_codesniffer: ^3.5
README
EHAK Locations
PHP Library to convert location into EHAK classification code and vice-versa
Install
composer require koren-software/ehak-locations
Usage
use \Koren\EHAK\EHAK; $ehak = new EHAK(); // init EHAK instance on latest data // Get EHAK code from location $countyCode = $ehak->getCode(EHAK::COUNTIES, 'EST', 'Harju maakond'); // 0037 $cityCode = $ehak->getCode(EHAK::CITIES, $countyCode, 'Tallinn'); // 0784 $ehak->getCode(EHAK::CITY_DISTRICTS, $cityCode, 'Haabersti linnaosa'); // 0176 $parishCode = $ehak->getCode(EHAK::PARISHES, $countyCode, 'Anija vald'); // 0141 $ehak->getCode(EHAK::VILLAGES, $parishCode, 'Aegviidu alev'); // 1088 // Get EHAK location from code $ehak->getLocation(EHAK::COUNTIES, 'EST', '0037'); // Harju maakond $ehak->getLocation(EHAK::CITIES, '0037', '0784'); // Tallinn $ehak->getLocation(EHAK::CITY_DISTRICTS, '0784', '0176'); // Haabersti linnaosa $ehak->getLocation(EHAK::PARISHES, '0037', '0141'); // Anija vald $ehak->getLocation(EHAK::VILLAGES, '0141', '1088'); // Aegviidu alev // Get full location from EHAK code $ehak->getFullLocation('0176'); //Gives: [ 'counties' => 'Harju maakond', 'cities' => 'Tallinn', 'city_districts' => 'Haabersti linnaosa', 'parishes' => '', 'villages' => '', ] // Get code from full location $ehak->getCodeFromFullLocation([ EHAK::COUNTIES => 'Harju maakond', EHAK::CITIES => 'Tallinn', EHAK::CITY_DISTRICTS => 'Haabersti linnaosa', EHAK::PARISHES => '', EHAK::VILLAGES => '', ]); // 0176
Development
Update data
src/data
directory holds different versions of EHAK data. To save new version or update old, run:
bin/update.php --path "EHAK XLSX PATH HERE"
Options
--output="FILENAME"
/-o FILENAME
- set different output destination--debug
/-d
- enable debug