diff --git a/docs/uri/7.0/rfc3986.md b/docs/uri/7.0/rfc3986.md index a5f02447..bd4e1ce5 100644 --- a/docs/uri/7.0/rfc3986.md +++ b/docs/uri/7.0/rfc3986.md @@ -111,8 +111,6 @@ The `Uri` class handles URI according to RFC3986 as such you can retrieve its st `toString` method. ```php -use League\Uri\Uri; - $uri = Uri::new("http://foo:bar@www.example.com:81/how/are/you?foo=baz#title"); echo $uri->toString(); //displays RFC3986 string representation @@ -126,8 +124,6 @@ The `Uri` instance can be json encoded using the same URI representation from Ja easier interoperability ```php -use League\Uri\Uri; - $uri = Uri::new("http://foo:bar@www.example.com:81/how/are/you?foo=baz#title"); json_encode($uri); //returns "http:\/\/foo:bar@www.example.com:81\/how\/are\/you?foo=baz#title" ``` @@ -141,8 +137,6 @@ may represent an invalid URI but can be used to display the URI to the client fo content of a `a` HTML tag. ```php -use League\Uri\Uri; - $uri = Uri::new('eXAMPLE://a/./b/../b/%63/%7bfoo%7d?foo[]=bar'); echo $uri->toString(); //displays 'example://a/./b/../b/%63/%7bfoo%7d?foo%5B%5D=bar' echo $uri->toNormalizedString(); //displays 'example://a/b/c/%7Bfoo%7D?foo%5B%5D=bar' @@ -152,8 +146,6 @@ echo $uri->toDisplayString(); //displays 'example://a/b/c/{foo}?foo[]=bar' HTML specific representation are added to allow adding URI to your HTML/Markdown page. ```php -use League\Uri\Uri; - $uri = Uri::new('eXAMPLE://a/./b/../b/%63/%7bfoo%7d?foo[]=bar'); echo $uri->toMarkdown(); //display '[example://a/b/c/{foo}?foo[]=bar](example://a/./b/../b/%63/%7bfoo%7d?foo%5B%5D=bar) @@ -168,8 +160,6 @@ echo $uri->toAnchorTag('my link'); You can also generate the Link `tag` and/or `header` depending on how you want your URI link to be rendered: ```php -use League\Uri\Uri; - $uri = Uri::new('https://example.com/my/css/v1.3'); echo $uri->toLinkTag(['rel' => 'stylesheet']); //display ' @@ -180,8 +170,6 @@ echo $uri->toLinkFieldValue(['rel' => 'stylesheet']); File specific representation are added to allow representing Unix and Windows Path. ```php -use League\Uri\Uri; - $uri = Uri::new('file:///c:/windows/My%20Documents%20100%2520/foo.txt'); echo $uri->toWindowsPath(); //display 'c:\windows\My Documents 100%20\foo.txt' @@ -378,24 +366,21 @@ $uri = Uri::new("ftp://thephpleague.com/fr/") echo $uri; //displays yolo://foo:bar@www.example.com:81?foo=baz#fine ~~~ -
- To ease building the instance, the `when` method is added to conditionally create your component. -```php -use League\Uri\Uri; + -$foo = ''; +```php echo Uri::new('https://uri.thephpleague.com/components/7.0/modifiers/') ->when( - '' !== $foo, - fn (Uri $uri) => $uri->withPath('/'.$foo), //on true - fn (Uri $uri) => $uri->withPath('/default'), //on false + fn (Uri $uri) => $uri->getPassword() !== null, + fn (Uri $uri) => $uri->withQuery('access=allowed'), //on true + fn (Uri $uri) => $uri->withQuery('access=deny'), //on false ) ->toString(); -// returns 'https://uri.thephpleague.com/default'; +// returns 'https://uri.thephpleague.com/components/7.0/modifiers/?access=deny'; ``` ## URI resolution