claudiodekker / word-generator
Generates random words by combining adjectives and nouns
Installs: 37 298
Dependents: 2
Suggesters: 0
Security: 0
Stars: 38
Watchers: 1
Forks: 3
Open Issues: 0
Requires
- php: ^7.3|~8.0.0|~8.1.0|~8.2.0|~8.3.0
Requires (Dev)
- phpunit/phpunit: ^8.4|^9.5.8
README
Word Generator
Generates creative words by randomly combining adjectives and nouns. This is useful for situations in which you need to generate a name that is unique or memorable.
Installation
To install the package, run the following command:
composer require claudiodekker/word-generator
Usage
<?php use ClaudioDekker\WordGenerator\Generator; echo Generator::generate(); // Outputs 'autumn firefly', 'crimson meadow', etc.
It's also possible to use a custom separator character, by passing it as the first argument:
<?php use ClaudioDekker\WordGenerator\Generator; echo Generator::generate('-'); // Outputs 'autumn-firefly', 'crimson-meadow', etc.
If you need words of a certain length or complexity, you can use the second argument to increase the number of adjectives used:
<?php use ClaudioDekker\WordGenerator\Generator; echo Generator::generate('-', 4); // Outputs 'crimson-autumn-wandering-firefly' etc.
Custom Word Lists
It is also possible to override the adjectives and nouns that can be used to generate the random phrases. For example, you may wish to do this if you want to use words that are themed or branded to your project.
To override the adjectives and nouns at the same time, you can pass an array of strings for both the first and second parameter:
<?php use ClaudioDekker\WordGenerator\Generator; $adjectives = ['adjective one', 'adjective two']; $nouns = ['noun one', 'noun two']; Generator::setWordLists($adjectives, $nouns);
If you only wish to override the adjectives, you can use the following:
<?php use ClaudioDekker\WordGenerator\Words\Adjective; $adjectives = ['adjective one', 'adjective two']; Adjective::setWordList($adjectives);
If you only wish to override the nouns, you can use the following:
<?php use ClaudioDekker\WordGenerator\Words\Noun; $nouns = ['noun one', 'noun two']; Noun::setWordList($nouns);
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email claudio@ubient.net instead of using the issue tracker.
License
The MIT License (MIT). Please see License File for more information.