bureaupartners / extract-address-from-text
With this package you can extract the address from a unformatted text string
Package info
github.com/bureaupartners/extract-address-from-text
pkg:composer/bureaupartners/extract-address-from-text
Fund package maintenance!
Requires
- php: ^7.2 | ^8.0
Requires (Dev)
- illuminate/support: ^10.48|^11.0|^12.0|^13.0
- phpunit/phpunit: ^13.0
- pragmarx/countries: ^1.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
With this package you can extract the address from a unformatted text string
Installation
Install composer packages
composer require bureaupartners/extract-address-from-text
Usage
use BureauPartners\ExtractAddressFromText\AddressExtractor; $extractor = new AddressExtractor($address['text']); $extractor->getAddress(); // Get all information $extractor->getRecipient(); $extractor->getStreet(); $extractor->getHouseNumber(); $extractor->getHouseNumberAddition(); $extractor->getPostalCode(); $extractor->getCity(); $extractor->getCountry()['code'];
The second argument is the country to assume when the address has no country
line (default NL):
$extractor = new AddressExtractor($address['text'], 'BE');
Countries
Postcodes are recognized for every European country. The country comes from, in this order:
- the country line, in most languages and also as an ISO code on the last line;
- a postcode of the assumed country;
- a country written behind the city ("1010 Wien, Austria");
- a postcode that can only belong to one country ("SW7 5DP", "00-468", "D-10117").
When none of these apply, getCountry()['code'] is an empty string.
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
License
See LICENSE.md