Download the PHP package goclearsky/name-gen without Composer
On this page you can find all versions of the php package goclearsky/name-gen. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download goclearsky/name-gen
More information about goclearsky/name-gen
Files in goclearsky/name-gen
Package name-gen
Short Description A CakePHP plugin to generate names for testing purposes
License MIT
Informations about the package name-gen
NameGen plugin for CakePHP
A plugin to generate random names as can be needed during development.
Installation
You can install this plugin into your CakePHP application using composer.
Use
The Generator class defines the getNames function.
Size is the number of people's names you are requesting. Gender is a single character. Locale is in the form of the typical locale values. Currently available are en_US. The last parameter indicates the cardinality of each name generated. If middle names are desired, then use 3, otherwise 2 provides given and family names only.
If cardinality is 3, each name is checked to ensure the given and middle names are different. Irrespective of cardinality, the set is checked to ensure each name is unique.
Typical use might be to create a shell that requests a set of names using getNames, then saves them to your database tables as needed. Could also be used to quickly generate test source data.
The above shell generates the following output and saves these names in the users table;
Contributing
All suggestions and feedback are welcome. One thing that could help the general appeal of the plugin is to have more seeds for different countries.
Limitations / ToDo's
Add exception handling. The algorithm isn't exhaustive. It is possible to; a) request more names than are possible to uniquely provide based on the size of the pool to pull from, and b) request more names than are reasonable to return by simply randomly picking a name and checking for uniqueness. Because of this, can actually return a result set smaller than the number requested. If this is important, either check the set size upon return, or reduce the requested size in relation to the pool size. As it is, 5000 names can be generated in less than 1 second on 2012 hardware.