All Projects → antonioribeiro → Random

antonioribeiro / Random

Licence: mit
Generate random strings or numeric values

Projects that are alternatives of or similar to Random

faker
Random fake data and struct generator for Go.
Stars: ✭ 67 (-1.47%)
Mutual labels:  random, faker
jRand
A Java library to generate random data for all sorts of things. Java random data faker
Stars: ✭ 27 (-60.29%)
Mutual labels:  random, faker
random
Random data generator AKA faker
Stars: ✭ 14 (-79.41%)
Mutual labels:  random, faker
randomdata
TYPO3 extensions to generate new random data or replace existing data with random data
Stars: ✭ 14 (-79.41%)
Mutual labels:  random, faker
fastfaker
Fast, concurrent fake data generator for any structure or type.
Stars: ✭ 21 (-69.12%)
Mutual labels:  random, faker
Golang Combinations
Golang library which provide an algorithm to generate all combinations out of a given string array.
Stars: ✭ 51 (-25%)
Mutual labels:  strings
Apex Domainbuilder
Framework to setup Apex test data in a highly flexible and readable way using the Test Data Builder pattern.
Stars: ✭ 61 (-10.29%)
Mutual labels:  patterns
Yesterday I Learned
Brainfarts are caused by the rupturing of the cerebral sphincter.
Stars: ✭ 50 (-26.47%)
Mutual labels:  random
Troschuetz.random
Fully managed library providing various random number generators and distributions.
Stars: ✭ 47 (-30.88%)
Mutual labels:  random
Fast Glob
🚀 It's a very fast and efficient glob library for Node.js
Stars: ✭ 1,150 (+1591.18%)
Mutual labels:  patterns
Go Pattern Examples
Examples of implement for awesome go patterns including usual design patterns, in easy understanding examples.
Stars: ✭ 65 (-4.41%)
Mutual labels:  patterns
React In Patterns Cn
React in patterns 中文版
Stars: ✭ 1,107 (+1527.94%)
Mutual labels:  patterns
Php Openapi Faker
Library to generate fake data for OpenAPI request/response/schemas
Stars: ✭ 54 (-20.59%)
Mutual labels:  faker
Php8 Design Patterns
Design patterns written in PHP 8
Stars: ✭ 63 (-7.35%)
Mutual labels:  patterns
Pgo
Go library for PHP community with convenient functions
Stars: ✭ 51 (-25%)
Mutual labels:  strings
Patterns Demos
Examples of Design Patterns in Java
Stars: ✭ 67 (-1.47%)
Mutual labels:  patterns
Random compat
PHP 5.x support for random_bytes() and random_int()
Stars: ✭ 7,950 (+11591.18%)
Mutual labels:  random
Simplebolt
🔩 Simple way to use the Bolt database
Stars: ✭ 58 (-14.71%)
Mutual labels:  strings
Tradestation
EasyLanguage indicators and systems for TradeStation
Stars: ✭ 65 (-4.41%)
Mutual labels:  patterns
Easy Random
The simple, stupid random Java beans/records generator
Stars: ✭ 1,095 (+1510.29%)
Mutual labels:  random

Random

Latest Stable Version Software License Build Status Code Coverage Scrutinizer Code Quality StyleCI

Generate random strings, numbers, bytes, patterns, and a lot more

Features

It generates cryptographically secure pseudo-random bytes (using random_bytes() and random_int()) to make:

  • Strings
  • Numbers (strings or integers)
  • Upper, lower and mixed case
  • Prefixed and suffixed random strings
  • Hexadecimal
  • Regex patterns ([abcd], [aeiou], [A-Z0123], [0-9a-f])
  • Raw strings, giving you whatever random_bytes() generates

Faker

If you have Faker installed it falls back to it, giving you access to random names, dates, cities, phones, and a lot more.

Install

Via Composer

$ composer require pragmarx/random

Usage

Basic array usage

$this->random = new PragmaRX\Random\Random();

$this->random->get(); /// will generate an alpha string which is the same of

$this->random->alpha()->get();

Should give you 16 chars (default size) string

   Ajv3ejknLmqwC36z

Defining the size

$this->random->size(32)->get();

Upper and lower case

$this->random->uppercase()->get();
$this->random->lowercase()->size(255)->get();

To get back to mixed case you can just:

$this->random->mixedcase()->get();

Defining a pattern

The pattern method uses regex, so you can:

$this->random->pattern('[abcd]')->get();

$this->random->pattern('[A-F0-9]')->get(); /// Hexadecimal

To get

   abcddcbabbacbbdabbcb

Numeric and Integer

The pattern method uses regex, so you can:

$this->random->numeric()->start(10)->end(20)->get();

To get

   (int) 18

But if you set the size

$this->random->numeric()->size(3)->get();

You'll get a string

   (string) 123

Hexadecimal

$this->random->hex()->size(10)->get();

Hexadecimal is uppercase by default, but you can get a lowercase by doing:

$this->random->hex()->lowercase()->get();

Prefix && Suffix

$this->random->hex()->prefix('#')->size(6)->lowercase()->get();

And you should get a random CSS color:

#fafafa

Of course, the same works for suffixes

$this->random->prefix('!')->suffix('@')->get();

Trivia

There are currently 43982 questions in the trivia database, and this is how you get them:

$this->random->trivia()->get();

$this->random->trivia()->count(2)->get();

You'll need to install the Trivia database package:

$ composer require pragmarx/trivia

Faker

If you install Faker

composer require fzaninotto/faker

You'll also have access to all of the Faker features, like:

$this->random->city()->get();

And also use all other features of Random

$this->random->prefix('city: ')->city()->lowercase()->get();

You can also change the faker class, you another one pleases you more:

$this->random->fakerClass(AnotherFaker\Factory::class)->date()->get();

Raw strings

Usually the package returns characters in the range of Base64 (A to Z, a to z and 0 to 9), but you can completely disable this feature and make it return whatever random_bytes() generates:

$this->random->raw()->get();

Change log

Please see CHANGELOG for more information on what has changed recently.

Testing

$ composer update
$ vendor/bin/phpunit

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].