balpom/web-link

HTTP链接的高级接口及其实现。

v1.1.1 2024-05-28 15:26 UTC

This package is auto-updated.

Last update: 2024-09-24 07:06:54 UTC


README

WebLink 组件扩展了 PSR-13 链接定义接口中的 LinkInterface 和 EvolvableLinkInterface

此 WebLink 组件扩展了 PSR-13 链接定义接口 并添加了额外的功能

interface WebLinkInterface extends LinkInterface
{
    // Returns the HTML tag which contains the link.
    public function getTag(): string;
    
    // For paired tags returns the HTML content between link open and close tags.
    public function getContent(): string;
    
    // Returns the attribute value or null, if attribute not exist.
    public function getAttribute(string $attr): string|int|float|bool|array|null;
}
interface EvolvableWebLinkInterface extends EvolvableLinkInterface, WebLinkInterface
{
    // Returns an instance with the specified tag.
    public function withTag(string $tag): static;

    // Returns an instance with the specified content.
    public function withContent(string $content): static;
}

基于 Symfony WebLink 组件的简单实现 https://github.com/symfony/web-link/

use Symfony\Component\WebLink\Link;
class WebLink extends Link implements EvolvableWebLinkInterface
{
// ...
}

许可

MIT 许可协议,请参阅 LICENSE.MD