Download the PHP package ohchiko/randomizer without Composer
On this page you can find all versions of the php package ohchiko/randomizer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ohchiko/randomizer
More information about ohchiko/randomizer
Files in ohchiko/randomizer
Package randomizer
Short Description A laravel helper to generate random text. Initial purpose is for user password.
License MIT
Homepage https://github.com/ohchiko/randomizer
Informations about the package randomizer
Randomizer
Randomizer is a php helper that helps your application to generate a random string.
This package is initially comes from an idea to generate a user's password.
Installation
Simply add the package to your composer.json
file and run composer update
.
Usage
To generate a random string, simply add below line to your code.
It will return a string containing random words concatenated with random punctutations. Below is the example result.
If you want to change the amount of words and/or punctuations in the result string, you may supply the amount in the method.
How It Works
Randomizer is generating a string which contains random words and random punctuations.
The words and punctuations are taken from a set. There are wordset
and punctset
which stores a list of words and punctuations.
By default, wordset
are taken from one of wordset files which identified by the language used. And punctset
is taken from an array of punctuations.
For example, the current available languages are: id
and en
, and the default language used is id
. The wordset file for those languages are: id_wordset
and en_wordset
. So, when generate
method called, it will take a random word(s) from id_wordset
file because the language used is id
.
The amount of words and punctuations to be taken is identified by the generate
method. The default value for both words and punctuations amount is 3
. See Available Methods section for detail.
You can change the language by calling the setLanguage
method before the generate
method. The argument supplied can be the language constants (which currently are LANG_ID
and LANG_EN
) or the language code (ex. en
).
If you prefered using your own wordset and/or punctset, you can tell Randomizer to use that instead by calling the setCustomWordset
and/or setCustomPunctset
method.
After that, you can check the customized wordset and punctset by calling getCustomWordset
and/or getCustomPunctset
method.
Available Methods
Besides the main method generate
, there also a number of other methods available.
Available Language Constants
The language constants are hardcoded, so in case to add a new wordset language, I need to update the code to add that language constant.
Testing
You can use phpunit from the package root to run the test file.
Support
If you ever encountered any issues while using this package, you may create a new issue report. If you have any idea on supporting this package (it may be a new wordsets, bug fixes, new feature, etc.), you may create a pull request and I will review it before it can be merged.
Please remember that this package is comes from an idea of creating a random user's password, so this package may not lead to what it is should be. This package soon may be a real randomizer, so please support me. :)
License
The MIT License (MIT). Please see LICENSE file for more information.
Credits
- dbrw: Full support on this package
- sastrawi/sastrawi: Indonesian word list
- paritytech/wordlist: English word list