Package Data | |
---|---|
Maintainer Username: | mikemike |
Maintainer Contact: | mgriffiths@gmail.com (Mike Griffiths) |
Package Create Date: | 2017-04-29 |
Package Last Update: | 2023-07-12 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-19 03:06:20 |
Package Statistics | |
---|---|
Total Downloads: | 421 |
Monthly Downloads: | 2 |
Daily Downloads: | 2 |
Total Stars: | 10 |
Total Watchers: | 3 |
Total Forks: | 6 |
Total Open Issues: | 0 |
Spin articles and text using this package.
Spinning allows an author to write an article or text but provide different variations of words or sentences. This class then plucks a sentence out at random. The idea being that lots of versions of the same article/text will be generated.
The text format is sometimes referred to as 'spyntax' or 'spintax'
{Hello|Hi|Hey} my name is {Frank|Bob|John}
may produce:
Hi my name is Frank
Hey my name is Frank
Hello my name is Bob
Hi my name is John
Hey my name is Bob
etc...
Add "mikemike/spinner": "dev-master"
to your composer.json
.
Run composer update
Add Mikemike\Spinner\SpinnerServiceProvider::class,
to the providers
array in your config/app.php
.
Add 'Spinner' => Mikemike\Spinner\SpinnerFacade::class,
to the aliases
array in your config/app.php
.
Add the class at the top of your class:
use Spinner;
And then call it anywhere in your code:
$spinner = new Spinner();
$string = '{Hey|Howdy|Hi there|Hi} {there|mate|bud|buddy}, {{how are|how\'re} {you|ya}|how you doin\'|how {you|ya} {feeling|hanging}|you doing {OK|alright}}?';
echo $spinner::process($string);
Nested spins are supported, as illustrated in the above example.