承接 karaca-tech/string-mask 相关项目开发

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

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

karaca-tech/string-mask

最新稳定版本:v0.1.1

Composer 安装命令:

composer require karaca-tech/string-mask

包简介

README 文档

README

String Mask

Latest Version on Packagist GitHub Tests Action Status GitHub Tests Action Status Total Downloads

This package is a simple string masker for Laravel.

Installation

You can install the package via composer:

composer require karaca-tech/string-mask

Usage

use KaracaTech\StringMask\Facades\Mask;

mask('John Doe')->keepFirstAndLastCharacter()->apply(); // J******e

Mask::fullname('John Doe'); // J*** D**
Mask::initials('John Doe'); // J.D.

// Let's spice things up a little bit
Mask::of('John Doe')
    ->silent()
    ->eachWord()
    ->keepFirstWord()
    ->keepFirstCharacter()
    ->then(fn(Masker $masked) => $masked->append('.'))
    ->apply(); // John D.

Using your own processors

All processors must be extended from KaracaTech\StringMask\Powder\Processor abstract class.

use KaracaTech\StringMask\Powder\Processor;
use KaracaTech\StringMask\MaskTarget;

class MyProcessor extends Processor
{
    public function execute(MaskTarget $string): string
    {
        // Do your magic here
    }
}

// or

class ProcessorWithParams extends Processor
{
    public function __construct(private AnotherClass $anotherClass)
    {
    }

    public function execute(MaskTarget $string): string
    {
        // Do your magic here
    }
}

Then you can use your processor like this:

Mask::of('John Doe')
    ->using(MyProcessor::class)
    ->using(MyOtherProcessor::class)
    ->using(ProcessorWithParams::class, new AnotherClass())
    ->apply();

For further examples, please check out the KaracaTech\StringMask\Concerete\Processors namespace.

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Contributions are always welcome, thanks to all of our contributors!

统计信息

  • 总下载量: 3.36k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 8
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 8
  • Watchers: 4
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2023-09-09