Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/apioo/psx-uri
URI, URL and URN value objects
https://github.com/apioo/psx-uri
Last synced: 3 days ago
JSON representation
URI, URL and URN value objects
- Host: GitHub
- URL: https://github.com/apioo/psx-uri
- Owner: apioo
- License: apache-2.0
- Created: 2016-03-31T13:09:37.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-05-10T18:01:16.000Z (6 months ago)
- Last Synced: 2024-10-12T21:12:54.951Z (29 days ago)
- Language: PHP
- Size: 66.4 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Uri
## About
Library which contains value objects to represent URI, URL and URNs. The value
objects are immutable so in case you change a value through a with* method you
get a new instance of that object. There is also a uri resolver class to resolve
a uri against a base uri.## Usage
```php
getPath(); // /bar
$uri->getQuery(); // foo=bar
$uri->getParameters(); // ['foo' => 'bar']$uri = $uri->withScheme('https');
$uri = $uri->withScheme('foo.com');echo $uri->toString(); // https://foo.com/bar?foo=bar
// the url object validates whether a scheme and host is available thus it is a valid url
$url = Url::parse($uri->toString());// a urn provides additional getter to get the urn specific components. A urn must start with urn:
$urn = Urn::parse('urn:uuid:6e8bc430-9c3a-11d9-9669-0800200c9a66');$urn->getNid(); // uuid
$urn->getNss(); // 6e8bc430-9c3a-11d9-9669-0800200c9a66
```