estasi/filter

数据文件过滤和归一化

1.1.0 2020-06-08 08:40 UTC

This package is auto-updated.

Last update: 2024-09-08 19:25:40 UTC


README

这是一个需要频繁使用、不可更改的过滤器集合。提供了一个简单的数据过滤链,允许您按指定顺序应用多个过滤器。

安装

使用composer安装

composer require estasi/filter

要求

  • PHP 7.4 或更高版本
  • ext-mbstring
  • ext-intl
  • 数据结构: composer require php-ds/php-ds
    Polyfill 与 estasi/filter 包一起安装。

用法

基本用法

<?php

declare(strict_types=1);

use Estasi\Filter\CamelCase;

$filter = new CamelCase();

echo $filter->filter('camel case'); // camelCase
// or 
echo $filter('camel_case'); // camelCase

链中有两个过滤器任务:显式(通过类声明)和通过工厂(数组)

<?php

declare(strict_types=1);

use Estasi\Filter\{Chain,Trim};

$string = ' camel case string   ';

$chain = new Chain(Chain::DEFAULT_PLUGIN_MANAGER, 'trim', 'camelCase');

// the same thing
$chain = new Chain();
$chain = $chain->attach(new Trim())
               ->attach([Chain::FILTER_NAME => 'camelCase']); // or attach('camelCase')

echo $chain->filter($string); // "camelCaseString"

许可证

本包所有内容均受BSD-3-Clause许可证许可。