PHP Classes
elePHPant
Icontem

PHP Random Text Generator: Generate test data from word files

Recommend this page to a friend!
  Info   View files Example   Screenshots Screenshots   View files View files (19)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2017-06-11 (20 hours ago) RSS 2.0 feedNot enough user ratingsTotal: 131 This week: 13All time: 8,492 This week: 77Up
Version License PHP version Categories
textrandomgenerator 1.1GNU General Publi...5PHP 5, Text processing, Testing
Description Author

This class can generate test data from word files.

It reads files with words of several types like female and male first names, surnames, verbs, pronouns, questions, etc..

The class can generate random text of specific types from random words read from files, like sentences with variable number of words, male and female first and last names, or common values for testing applications like random login names, email addresses, random age, etc..

Currently the package provides files with words for English and Russian.

Innovation Award
PHP Programming Innovation award nominee
April 2017
Number 7
Some applications need to be tested using fake data that must be as close as possible to real data.

This class can generate random text for testing purposes that can simple values like random names, or more complex text like complete sentences in different languages.

Manuel Lemos
  Performance   Level  
Name: Max Stemplevski <contact>
Classes: 5 packages by
Country: Belarus Belarus
Innovation award
Innovation award
Nominee: 2x

Details

TextRandomGenerator

Generate random sentences/headers/passwords/first(last) names/emails

*

General methods:

initialize($lang = 'eng') - Use always for load words from language files

generateRandomHeader() - Generate random string for header

generateRandomString($length = 10, $spec = false) - Method for generate random string (with special symbols)

generateRandomSentences($count_of_sentences = 5, $count_of_words = 0) - Generate random sentences string

generateFirstName($gender = 'Male') - Generate random First Name from file (by gender)

generateLastName($gender = 'Male') - Generate random First Name from file (by gender)

generateYearsOld($min = 18, $max = 91) - Generate random year value (18..91)

generateBirthday($age) - Generate random birthday string by age

generateEmail($firstname, $lastname, $birthday) - Generate email (by firstname,lastname,birthday )

generateLogin($firstname, $lastname, $birthday) - Generate login (by firstname,lastname,birthday )

Example of using:

*

use RandomText\TextGenerator;
//...

TextGenerator::initialize();

$api_secret = TextGenerator::generateRandomString(30);
$api_password = TextGenerator::generateRandomString(12, true);
$gender = rand(0, 1) ? 'Male' : 'Female';
$firstname = TextGenerator::generateFirstName($gender);
$lastname = TextGenerator::generateLastName($gender);
$age = TextGenerator::generateYearsOld(18, 68);
$birthday = TextGenerator::generateBirthday($age);
$email = TextGenerator::generateEmail($firstname, $lastname, $birthday);
$login = TextGenerator::generateLogin($firstname, $lastname, $birthday);
$password = TextGenerator::generateRandomString(12, true);

> Allowed 2 languages RUS and ENG(by default)

Screenshots  
  • Like_Lorem
  • example1
  Files folder image Files  
File Role Description
Files folder imageeng (8 files)
Files folder imagerus (8 files)
Accessible without login Plain text file index.php Example Example script
Accessible without login Plain text file README.md Doc. Documentation
Plain text file TextGenerator.php Class Class source

  Files folder image Files  /  eng  
File Role Description
  Accessible without login Plain text file female_firstnames.txt Doc. Documentation
  Accessible without login Plain text file male_firstnames.txt Doc. Documentation
  Accessible without login Plain text file popular_verbs.txt Doc. Documentation
  Accessible without login Plain text file pronouns.txt Doc. Documentation
  Accessible without login Plain text file question_words.txt Doc. Documentation
  Accessible without login Plain text file surnames.txt Doc. Documentation
  Accessible without login Plain text file vincodes.txt Doc. Documentation
  Accessible without login Plain text file words.txt Doc. Documentation

  Files folder image Files  /  rus  
File Role Description
  Accessible without login Plain text file female_firstnames.txt Doc. Documentation
  Accessible without login Plain text file male_firstnames.txt Doc. Documentation
  Accessible without login Plain text file popular_verbs.txt Doc. Documentation
  Accessible without login Plain text file pronouns.txt Doc. Documentation
  Accessible without login Plain text file question_words.txt Doc. Documentation
  Accessible without login Plain text file surnames.txt Doc. Documentation
  Accessible without login Plain text file vincodes.txt Doc. Documentation
  Accessible without login Plain text file words.txt Doc. Documentation

 Version Control Unique User Downloads Download Rankings  
 90%
Total:131
This week:13
All time:8,492
This week:77Up