Note
This is a fork of the Original IRI class written by Markus Lanthaler. I maintain it in my spare time to keep it alive and usable on the latest PHP versions. Code is more or less maintained but not developed any further. If you wanna participate, feel free to open a pull request!
This is a simple PHP class to ease IRI handling. Currently it just supports parsing of IRIs and relative IRI resolution.
With more than 800 tests, this class is extensively tested.
The easiest way to use IRI is to integrate it as a dependency in your project's composer.json file:
{
"require": {
"sweetrdf/iri": "^1"
}
}or run:
composer install sweetrdf/iri
Of course you can also just download an archive from Github.
This library is intented to be a drop-in replacement for the original ml/iri library.
However, the IRI class was adapted to be more type safe:
- Added
declare(strict_types=1);to the file - Added explicit type information to each class property
- Added explicit return value types to each class method
❗ IRI does not throw an InvalidArgumentException anymore if an invalid value was given in the constructor!
In this case PHP itself will complain.
Most test cases come either directly from the URI specification, from Graham Klyne's, or Tim Berners-Lee's test suite.