Skip to content

Commit

Permalink
Adding UriStringProvider interface
Browse files Browse the repository at this point in the history
  • Loading branch information
nyamsprod committed Dec 25, 2024
1 parent 6871415 commit 6feff57
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 4 deletions.
5 changes: 1 addition & 4 deletions Contracts/UriInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,12 @@
*
* @method string|null getUsername() returns the user component of the URI.
* @method string|null getPassword() returns the scheme-specific information about how to gain authorization to access the resource.
* @method string|null toUnixPath() returns the Unix filesystem path. The method returns null for any other scheme
* @method string|null toWindowsPath() returns the Windows filesystem path. The method returns null for any other scheme
* @method string|null toRfc8089() returns a string representation of a File URI according to RFC8089. The method returns null for any other scheme
* @method string|null getOrigin() returns the URI origin as described in the WHATWG URL Living standard specification
* @method string toNormalizedString() returns the normalized string representation of the URI
* @method array toComponents() returns an associative array containing all the URI components.
* @method self normalize() returns a new URI instance with normalized components
* @method self resolve(UriInterface $uri) resolves a URI against a base URI using RFC3986 rules
* @method self relativize(UriInterface $uri) relativize a URI against a base URI using RFC3986 rules
* @method self|null getOrigin() returns the URI origin as described in the WHATWG URL Living standard specification
* @method bool isOpaque() tells whether the given URI object represents an opaque URI.
* @method bool isAbsolute() tells whether the URI represents an absolute URI.
* @method bool isNetworkPath() tells whether the URI represents a network path URI.
Expand Down
71 changes: 71 additions & 0 deletions Contracts/UriStringProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php

/**
* League.Uri (https://uri.thephpleague.com)
*
* (c) Ignace Nyamagana Butera <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace League\Uri\Contracts;

use DOMException;
use JsonSerializable;

interface UriStringProvider extends JsonSerializable
{
/**
* Returns the string representation as a URI reference.
*
* @see http://tools.ietf.org/html/rfc3986#section-4.1
*/
public function toString(): string;

/**
* Returns the normalized string representation of the URI.
*
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-6.2
*/
public function toNormalizedString(): ?string;

/**
* Returns the human-readable string representation of the URI.
*
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-6.2
*/
public function toDisplayString(): ?string;

/**
* Returns the string representation as a URI reference.
*
* @see http://tools.ietf.org/html/rfc3986#section-4.1
* @see ::__toString
*/
public function jsonSerialize(): string;

/**
* Returns the HTML string representation of the anchor tag with the current instance as its href attribute.
*
* @throws DOMException
*/
public function toAnchorTag(?string $content = null, ?string $class = null, ?string $target = null): string;

/**
* Returns the markdown string representation of the anchor tag with the current instance as its href attribute.
*/
public function toMarkdown(?string $content = null): string;

/**
* Returns the Unix filesystem path. The method returns null for any other scheme.
*/
public function toUnixPath(): ?string;

/**
* Returns the Windows filesystem path. The method returns null for any other scheme.
*/
public function toWindowsPath(): ?string;
}

0 comments on commit 6feff57

Please sign in to comment.