thoom/generator

This package is abandoned and no longer maintained. No replacement package was suggested.

PHP 5.3 classes used to generate strings such as UUID and alphanumeric

dev-master 2013-02-02 05:34 UTC

This package is not auto-updated.

Last update: 2023-11-11 10:07:10 UTC


README

These classes are static classes that generate various values that you may need in the an application. I frequently use the RandomString methods to build temporary passwords, and the Uuid class to create unique ids to entities that are put/posted to a collections url.

Usage

To create a Uuid:

$uuid = Thoom\Generator\Uuid::v4();
//outputs something like: ef8dbbaf-681a-4329-b58c-262a6c2c1fb4

To create a random alphanumeric string, lowercase only, 16 characters:

use Thoom\Generator\RandomString;

// .... code ... //

$string = RandomString::alnum(16, RandomString::ALPHANUM_LOWER);
//outputs something like: asb0z93dg91st73l

To add custom characters (like a dash) to a random string:

use Thoom\Generator\RandomString;

// .... code ... //

$string = RandomString::user(16, array('-'), RandomString::ALPHANUM_LOWER);
//outputs something like: p2am-53s9xrzb63n