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
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。