-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
72 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,20 +30,19 @@ At this point this library depends on another own library [madkom/collection](ht | |
|
||
1. [rize/uri-template](https://packagist.org/packages/rize/uri-template): for UriTemplate impl | ||
2. [true/punycode](https://packagist.org/packages/true/punycode): for IDNA domain names conversion | ||
3. [ml/iri](https://packagist.org/packages/ml/iri): for parsing URI _(this will be replaced with own impl because od to many dependencies and not as much RFC compliant impl)_ | ||
|
||
## Usage | ||
|
||
Parsing url string: | ||
|
||
```php | ||
use Madkom\Uri\Parser; | ||
use Madkom\Uri\UriFactory; | ||
use Madkom\Uri\Uri; | ||
|
||
$parser = new Parser(); | ||
$factory = new UriFactory(); | ||
|
||
/** @var Uri $uri */ | ||
$uri = $parser->parse('http://user:[email protected]/some/path?and=query¶m=2#fragment'); | ||
$uri = $factory->createUri('http://user:[email protected]/some/path?and=query¶m=2#fragment'); | ||
|
||
$uri->getScheme(); // Instance of \Madkom\Uri\Scheme\Http | ||
$uri->getAuthority(); // Instance of \Madkom\Uri\Authority | ||
|
@@ -56,13 +55,13 @@ $uri->getQuery(); // Instance of \Madkom\Uri\Query | |
Parsing isbn uri: | ||
|
||
```php | ||
use Madkom\Uri\Parser; | ||
use Madkom\Uri\UriFactory; | ||
use Madkom\Uri\Uri; | ||
|
||
$parser = new Parser(); | ||
$factory = new UriFactory(); | ||
|
||
/** @var Uri $uri */ | ||
$uri = $parser->parse('isbn:978-83-283-0525-0'); // Instance of \Madkom\Uri\Uri | ||
$uri = $factory->createUri('isbn:978-83-283-0525-0'); // Instance of \Madkom\Uri\Uri | ||
|
||
$uri->getScheme(); // Instance of \Madkom\Uri\Scheme\Custom | ||
$uri->getAuthority(); // NULL | ||
|
@@ -106,9 +105,9 @@ $uri->toString(); // https://user:pass@[::1]:443/some/path?name=value | |
## TODO | ||
|
||
* [ ] Implement Uri to string conversion | ||
* [ ] Implement fragment component | ||
* [ ] Replace IRI library with RFC Regex in `\Madkom\Uri\Parser` | ||
* [ ] Implement additional parsing modes in `\Madkom\Uri\Parser\Query` for various languages _(parameter duplicate problem)_ | ||
* [x] Implement fragment component | ||
* [x] Replace IRI library with RFC Regex in `\Madkom\Uri\Parser` | ||
* [x] Implement additional parsing modes in `\Madkom\Uri\Parser\Query` for various languages _(parameter duplicate problem)_ | ||
* [ ] Implement normalization | ||
* [ ] Implement UriReference based on *RFC3986* | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php declare(strict_types=1); | ||
/** | ||
* Created by PhpStorm. | ||
* User: mbrzuchalski | ||
* Date: 29.02.16 | ||
* Time: 11:47 | ||
*/ | ||
namespace Madkom\Uri\Scheme; | ||
|
||
use Madkom\Uri\Component\Authority; | ||
use Madkom\Uri\Component\Fragment; | ||
use Madkom\Uri\Component\Path; | ||
use Madkom\Uri\Component\Query; | ||
use Madkom\Uri\Uri; | ||
|
||
/** | ||
* Class Isbn | ||
* @package Madkom\Uri\Scheme | ||
* @author Michał Brzuchalski <[email protected]> | ||
*/ | ||
class Isbn implements Scheme | ||
{ | ||
const PROTOCOL = 'isbn'; | ||
/** | ||
* Compose uri from parsed components | ||
* @param Authority $authority | ||
* @param Path $path | ||
* @param Query $query | ||
* @param Fragment $fragment | ||
* @return Uri | ||
*/ | ||
public function compose(Authority $authority, Path $path, Query $query, Fragment $fragment) : Uri | ||
{ | ||
return new Uri($this, null, $path); | ||
} | ||
|
||
/** | ||
* Retrieve uri string representation | ||
* @param Uri $uri | ||
* @param int $flags | ||
* @return string | ||
*/ | ||
public function toString(Uri $uri, int $flags = 0) : string | ||
{ | ||
return ''; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,6 @@ function it_can_parse_valid_url() | |
|
||
function it_fails_on_scheme_missing() | ||
{ | ||
$this->shouldThrow(MissingSchemeParseUriException::class)->during('create', ['//user:[email protected]/path/to']); | ||
$this->shouldThrow(MissingSchemeParseUriException::class)->during('createUri', ['//user:[email protected]/path/to']); | ||
} | ||
} |