头图

Introduction

This library provides the generation of English words and sentences. It does not involve unit tests or data models. It supports custom vocabulary, supports custom return word\sentence length and return type (string, array, object, json), it does not Your memory will be insufficient because of the customized large-file lexicon. Lightweight and fast to help you generate data.

Install

composer require kayw-geek/php-mock -vvv

use

//mock 单个单词
$mockWord = new \KaywGeek\MockWords();
$mockWord->mockWord();
//mock 单条句子
$mockSentence = new \KaywGeek\MockSentence();
$mockSentence->mockWord();

//mock 指定格式指定数量的单词
//参数1 想要返回的指定格式 
/**
  * FORMAT_ARRAY;
  * FORMAT_OBJECT;
  * FORMAT_JSON;
  * FORMAT_STRING; 
  */
//参数2 想要返回的长度
$mockWord->mockWords(\KaywGeek\MockWords::FORMAT_ARRAY,5);
$mockSentence->mockWords(\KaywGeek\MockWords::FORMAT_JSON,6);

//自定义词库使用
$filePath = 'custom-words.txt';
$mockSentence = new \KaywGeek\MockSentence($filePath);

If you use the Yii2 framework, it also has packages specially adapted to the Yii2 framework.
Yii2 version Github
PHP version Github


bug开发
393 声望4 粉丝