2017 © Pedro Pelรกez
 

library randbuilder

A data builder

image

renshan/randbuilder

A data builder

  • Wednesday, January 18, 2017
  • by renshan
  • Repository
  • 1 Watchers
  • 0 Stars
  • 15 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

RandBuilder

A random data generator, (*1)

Schema


$schema = array( "object" => array( "name" => array( "type" => "string", "length" => 10, "prefix" => "builder_", "end" => "_redliub", "unique" => true ), "hash" => array( "type" => "string", "length" => array(10,20), "reducer" => "md5" ), "number" => array( "type" => "integer", "range" => array(10, 100), "unique" => true ), "price" => array( "type" => "float", "range" => array(100, 1000), "precision" => 2 ) ), "count" => 10 // How many object will be make );

Ok, $scheme is a scheme used to generate the data you want, it's an array php, this array contains two items: object and count, object is the real schema, and count indicate how many you want.
Let's see the object, however of whatever, object is an array, items in object are fields to be generated, the most important thing is to define a field, items has a few attributes:
* type โ€ƒโ€ƒโ€ƒโ€ƒtype is required, now RandBuilder support three types: string, integer and float.
* length โ€ƒโ€ƒโ€ƒโ€ƒtype is required if type is string
* prefix โ€ƒโ€ƒโ€ƒโ€ƒprefix defaults to ''
* end โ€ƒโ€ƒโ€ƒโ€ƒend defaults to '' * unique โ€ƒโ€ƒโ€ƒโ€ƒunique indicate the field is unique or not, defaults to false
* range โ€ƒโ€ƒโ€ƒโ€ƒrange is not required for integer and float, it indicate the min and the max number to be generated * precision โ€ƒโ€ƒโ€ƒโ€ƒrange for float, it default to 0, (*2)

Note: if unique is true, the actual quantity produced may be less than the specified quantity., (*3)

Example

```php, (*4)

use RandBuilder\Builder;, (*5)

$schema = array( "object" => array( "name" => array( "type" => "string", "length" => 10, "prefix" => "builder_", "end" => "_redliub", "unique" => true ), "hash" => array( "type" => "string", "length" => array(10,20), "reducer" => "md5" ), "number" => array( "type" => "integer", "range" => array(10, 100), "unique" => true ), "price" => array( "type" => "float", "range" => array(100, 1000), "precision" => 2 ) ),, (*6)

"count" => 10  // How many object will be make

);, (*7)

$objects = Builder::build($schema); ``, (*8)

The Versions

18/01 2017

dev-master

9999999-dev

A data builder

  Sources   Download

MIT

The Requires

  • php >=7.0.0

 

by Avatar renshan

18/01 2017

v1.0.0

1.0.0.0

A data builder

  Sources   Download

MIT

The Requires

  • php >=7.0.0

 

by Avatar renshan