Skip to content

Commit 420c680

Browse files
committed
Adding UriStringProvider interface
1 parent 6871415 commit 420c680

File tree

2 files changed

+72
-4
lines changed

2 files changed

+72
-4
lines changed

Contracts/UriInterface.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,12 @@
2424
*
2525
* @method string|null getUsername() returns the user component of the URI.
2626
* @method string|null getPassword() returns the scheme-specific information about how to gain authorization to access the resource.
27-
* @method string|null toUnixPath() returns the Unix filesystem path. The method returns null for any other scheme
28-
* @method string|null toWindowsPath() returns the Windows filesystem path. The method returns null for any other scheme
29-
* @method string|null toRfc8089() returns a string representation of a File URI according to RFC8089. The method returns null for any other scheme
27+
* @method string|null getOrigin() returns the URI origin as described in the WHATWG URL Living standard specification
3028
* @method string toNormalizedString() returns the normalized string representation of the URI
3129
* @method array toComponents() returns an associative array containing all the URI components.
3230
* @method self normalize() returns a new URI instance with normalized components
3331
* @method self resolve(UriInterface $uri) resolves a URI against a base URI using RFC3986 rules
3432
* @method self relativize(UriInterface $uri) relativize a URI against a base URI using RFC3986 rules
35-
* @method self|null getOrigin() returns the URI origin as described in the WHATWG URL Living standard specification
3633
* @method bool isOpaque() tells whether the given URI object represents an opaque URI.
3734
* @method bool isAbsolute() tells whether the URI represents an absolute URI.
3835
* @method bool isNetworkPath() tells whether the URI represents a network path URI.

Contracts/UriStringProvider.php

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?php
2+
3+
/**
4+
* League.Uri (https://uri.thephpleague.com)
5+
*
6+
* (c) Ignace Nyamagana Butera <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
namespace League\Uri\Contracts;
15+
16+
use DOMException;
17+
use JsonSerializable;
18+
19+
interface UriStringProvider extends JsonSerializable
20+
{
21+
/**
22+
* Returns the string representation as a URI reference.
23+
*
24+
* @see http://tools.ietf.org/html/rfc3986#section-4.1
25+
*/
26+
public function toString(): string;
27+
28+
/**
29+
* Returns the normalized string representation of the URI.
30+
*
31+
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-6.2
32+
*/
33+
public function toNormalizedString(): ?string;
34+
35+
/**
36+
* Returns the human-readable string representation of the URI.
37+
*
38+
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-6.2
39+
*/
40+
public function toDisplayString(): ?string;
41+
42+
/**
43+
* Returns the string representation as a URI reference.
44+
*
45+
* @see http://tools.ietf.org/html/rfc3986#section-4.1
46+
* @see ::__toString
47+
*/
48+
public function jsonSerialize(): string;
49+
50+
/**
51+
* Returns the HTML string representation of the anchor tag with the current instance as its href attribute.
52+
*
53+
* @throws DOMException
54+
*/
55+
public function toAnchorTag(?string $content = null, ?string $class = null, ?string $target = null): string;
56+
57+
/**
58+
* Returns the markdown string representation of the anchor tag with the current instance as its href attribute.
59+
*/
60+
public function toMarkdown(?string $content = null): string;
61+
62+
/**
63+
* Returns the Unix filesystem path. The method returns null for any other scheme.
64+
*/
65+
public function toUnixPath(): ?string;
66+
67+
/**
68+
* Returns the Windows filesystem path. The method returns null for any other scheme.
69+
*/
70+
public function toWindowsPath(): ?string;
71+
}

0 commit comments

Comments
 (0)