tr33m4n/url-object

PSR-7 URI对象的简单比较器

v1.3.1 2021-05-02 14:07 UTC

This package is auto-updated.

Last update: 2024-08-29 05:13:17 UTC


README

本模块便于对PSR-7 URI对象每个组件的基本比较

安装

composer require tr33m4n/uri-comparator

如何使用

$comparator = \tr33m4n\UriComparator\Comparator::compare(
    'https://example.com:1234',
    'https://another-example.com:1234?this=test&another=something',
    \League\Uri\Http::createFromString('https://example.com:1234'),
    \League\Uri\Uri::createFromString('https://another-example.com:1234?this=test&another=something')
    // An instance of `\Psr\Http\Message\UriInterface`
    // etc...
);

var_dump($comparator->matchPort());
var_dump($comparator->matchHost());
var_dump($comparator->matchScheme());
var_dump($comparator->matchPath());
// bool(true)
// bool(false)
// bool(true)
// bool(true)

// From array of URI's
$comparator = \tr33m4n\UriComparator\Comparator::compareArray([
    'https://example.com:1234',
    'https://another-example.com:1234?this=test&another=something',
    \League\Uri\Http::createFromString('https://example.com:1234'),
    \League\Uri\Uri::createFromString('https://another-example.com:1234?this=test&another=something')
]);