honda/url-pattern-matcher

检查给定的路径是否与给定的模式匹配。

1.1.1 2022-01-22 10:20 UTC

This package is auto-updated.

Last update: 2024-09-18 19:46:51 UTC


README

Tests Formats Version Total Downloads License

检查给定的路径(如 /articles/4)是否与给定的模式(如 /articles/*)匹配。

安装

您可以通过composer安装此包

composer require honda/url-pattern-matcher

使用方法

尾部斜杠将被忽略,因此如果给定 /example,匹配器将匹配 /exampleexampleexample//example/

use Honda\UrlPatternMatcher\UrlPatternMatcher;
$urlPatternMatcher = new UrlPatternMatcher('/articles/edit');

$urlPatternMatcher->match('/articles');

// See fnmatch() function for reference on how the matching works.
$urlPatternMatcher->match('/articles/*/edit');

// Matches if the path starts with /articles
$urlPatternMatcher->match('^/articles');

// Matches if the path ends with /articles
$urlPatternMatcher->match('/articles$');

测试

此包有100%的代码覆盖率,这在大多数情况下很少见,大多数情况下是无用的,但感觉很好 :)。

composer test

Url Pattern MatcherFélix Dorn 根据 MIT许可 创建。