hyungju/readable-url

Generate readable random phrases for URLs

1.2.5 2021-02-22 15:07 UTC

README

Logo

All Contributors

Generate readable random phrases for URLs

Badge Badge Badge Badge Badge Badge Badge Badge

How To Use

This library is available on packagist. To install,

composer require hyungju/readable-url

Then create ReadableURL Class

$readableURL = new HyungJu\ReadableURL();

You can pass four parameters to the class.

use HyungJu\ReadableURL;
// Takes 4 parameters.
// 1. A boolean value - If true, returns string in CamelCase, else lowercase.
// 2. An integer value - The number of words to be generated in the string. (Between 2 and 10).
// 3. A string - The seperator between the words.
// 4. Language Class - Currently Supported : HyungJu\Language\En, HyungJu\Language\Ko. pass language instance! the default is HyungJu\Language\En
$readableURL = new ReadableURL();
//$readableURL = new HyungJu\ReadableURL(false, 5, '-', new HyungJu\Language\Ko()); // Other options.

To generate ReadableURL, call the generate() function.

use HyungJu\ReadableURL;

...

$readableURL = new ReadableURL();
$readableURL->generate();
// > QuickScrawnyCamp

In addition, the following are simple to:

use HyungJu\ReadableURL;

...

$str = ReadableURL::gen();
// > FierceSaltyComparison

This can be used to add to the end of a URL.

Example: https://example.com/photos/ForgetfulHarshEgg

For best results, use an integer value of 3, 4, or 5.

Test

composer test

Adding new language

  1. Add wordsets to src/words/[language code]. adjectives.txt and nouns.txt are needed.

  2. Create your language class src/Language/[language code].php. the class name must be started with Uppercase.

  3. Implement the class based on other languages already implemented (korean and english)

  4. Register your language in src/Language/LanguageHelper.php.

  5. (optional) Add test for your language.

Versioning

We use SemVer for versioning this project.

License

MIT License

Contributors ✨

Thanks goes to these wonderful people (emoji key):


도다

💻

Yukihyõ

💻

This project follows the all-contributors specification. Contributions of any kind welcome!