jaysn/spongemock 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

jaysn/spongemock

最新稳定版本:1.0.0

Composer 安装命令:

composer require jaysn/spongemock

包简介

A PHP Helper for mOCkInG tExt LIkE sPoNgEbOb WOuLd

README 文档

README

License php 7.1+

A PHP implementation of nkrim/spongemock to mOCk SoMe TexT lIKe SpONGebOb wOuLd in PHP

Installation

Installation using Composer

composer require jaysn/spongemock

Usage

Basic Usage

Using instances of the Mocker is recommended for processing multiple strings with the same settings

use Jaysn\Spongemock\Mocker;

$mocker = new Mocker();

// $mockedText would be sth like 'MoCK sOMe tExt LIkE sPoNgEbOb WOuLd'
$mockedText = $mocker->process('mock some text like spongebob would');

Setting the diversity bias or custom seed for RNG

The Constructor of Mocker accepts Parameters $diversityBias and $randomSeed.

diversityBias is used for the distribution of case-swaps. Using a higher bias causes more swaps between upper and lowercase, using a lower value reduces them accordingly.

randomSeed is a custom seed for the Mersenne Twister Random Number Generator used for randomly swapping cases based on diversityBias. Settings this value allows deterministic creation of strings, as mt_srand() is used to pre-seed the RNG with this value for each call of Mocker::process(), thus returning the same string if given the same seed.

// less random swaps
$mocker = new Mocker(0.2);
$mocked = $mocker->process('mock some text like spongebob would');

// More random swaps (balanced distribution)
$mocker = new Mocker(0.8);
$mocked = $mocker->process('mock some text like spongebob would');

// default swapping but custom seed (for reproducable results)
$mocker = new Mocker(0.5, 42);
$mocked = $mocker->process('mock some text like spongebob would');

Static Usage

⚠ This is not recommended if processing multiple strings as every call creates another instance of the Mocker Class

use Jaysn\Spongemock\Mocker;

// $mockedText would be sth like 'MoCK sOMe tExt LIkE sPoNgEbOb WOuLd'
$mockedText = Mocker::mock('mock some text like spongebob would');

Setting the diversity bias or custom seed for RNG

// less random swaps
$mocked = Mocker::mock('mock some text like spongebob would', 0.2);


// More random swaps (balanced distribution)
$mocked = Mocker::mock('mock some text like spongebob would', 0.8);

// default swapping but custom seed (for reproducable results)
$mocked = Mocker::mock('mock some text like spongebob would', 0.5, 42);

Now go ahead and mOCk SoMe TexT lIKe SpONGebOb wOuLd

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-11-09

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固