承接 accentinteractive/disallowlister 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

accentinteractive/disallowlister

Composer 安装命令:

composer require accentinteractive/disallowlister

包简介

Test a string against a disallowlist. Useful for user forms and such.

README 文档

README

Latest Version on Packagist Build Status Quality Score Total Downloads

This little package tests a string against a disallowlist.

If you are looking for a Laravel-specific implementation, see https://github.com/accentinteractive/laravel-disallowlister

The isDisallowed() method can use wildcards, like *.

Under the hood, accentinteractive/disallowtester uses fnmatch(), so you can use the same wildcards as in that php function (the globbing wildcard patterns):

  • *sex* disallows sex, sexuality and bisexual.

  • cycle* disallows cycle and cycles, but not bicycle.

  • m[o,u]m disallows mom and mum, but allows mam.

  • m?n disallows man and men, but allows moon.

  • Installation

  • Examples

  • Config settings

Installation

You can install the package via composer:

composer require accentinteractive/disallowlister

Usage

Setting the disallowlist

You can pass the disallowlist in the constructor or via other methods.

// Pass the disallowlist in the constructor 
$disallowLister = new DisallowLister(['foo']); // ['foo']

// Set the disallowlist in the setter method
$disallowLister->setDisallowList(['bar']); // ['bar']

// Add an item to the disallowlist
$disallowLister->add('baz'); // ['bar', 'baz']

// Add multiple items to the disallowlist
$disallowLister->add(['bat', 'fiz']); // ['bar', 'baz', 'bat', 'fiz']

// Remove an item from the disallowlist
$disallowLister->remove('fiz'); // ['bar', 'baz', 'bat']

// Remove multiple items from the disallowlist
$disallowLister->remove(['baz', 'bat']); // ['bar']

Checking data against the disallowlist

## Literal string
$disallowLister = new DisallowLister(['bar', 'foo']);

$disallowLister->isDisallowed('bar'); // Returns true
$disallowLister->isDisallowed('bars'); // Returns false

## Wildcards
// Under the hood, `accentinteractive/disallowtester` 
// uses `fnmatch()`, so you can use the same 
// wildcards as in that php function (the 
// globbing wildcard patterns):
(new DisallowLister(['b?r']))->isDisallowed('bar'); // Returns true
(new DisallowLister(['m[o,u]m']))->isDisallowed('mom'); // Returns true
(new DisallowLister(['*bar*']))->isDisallowed('I like crowbars'); // Returns true

Case sensitivity

// By default, matching is not case sensitive
(new DisallowLister(['bar']))->isDisallowed('BAR'); // Returns true

// To set case sensitive matching
(new DisallowLister(['bar']))->caseSensitive(true)->isDisallowed('BAR'); // Returns false

Whole word checking

// By default the entire string is checked. 
(new DisallowLister())->setDisallowList(['bar'])->isDisallowed('My favorite bar'); // Returns false

// Check word for word.
(new DisallowLister())->setDisallowList(['bar'])->setWordForWord(true)->isDisallowed('My favorite bar'); // Returns true

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email joost@accentinteractive.nl instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 40
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 9
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-08-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固