tr33m4n/url-object

Conveniently manipulate an URL string


License
MIT

Documentation

uri-comparator

This module facilitates the basic comparison of each component of a PSR-7 URI object

Installing

composer require tr33m4n/uri-comparator

How to use

$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')
]);