2017 © Pedro Peláez
 

library spintax

Spintax {parsing|processing} library.

image

chilldev/spintax

Spintax {parsing|processing} library.

  • Saturday, May 31, 2014
  • by rafal.wrzeszcz
  • Repository
  • 2 Watchers
  • 14 Stars
  • 1,523 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 4 Forks
  • 1 Open issues
  • 3 Versions
  • 25 % Grown

The README.md

ChillDev Spintax

ChillDevSpintax is a library which offers implementation of some commonly used patterns used in Symfony2 DI., (*1)

Build Status Scrutinizer Quality Score Coverage Status Dependency Status, (*2)

Installation

This library is provided as Composer package. To install it simply add following dependency definition to your composer.json file:, (*3)

"chilldev/spintax": "dev-master"

Replace dev-master with different constraint if you want to use specific version., (*4)

Note: This library requires PHP 5.4., (*5)

Usage

The simplest usage that will mostly fulfill your needs is to simple parse the spintax string and generate random variation of it:, (*6)

use ChillDev\Spintax\Parser;

$spintax = Parser::parse('Schrödinger’s Cat is {dead|alive}.');
$string = $spintax->generate();

But there is much more that than that in our library. First of all nested structures are supported:, (*7)

use ChillDev\Spintax\Parser;

$spintax = Parser::parse('I {love {PHP|Java|C|C++|JavaScript|Python}|hate Ruby}.');
$string = $spintax->generate();

Still not finished! With our brilliant library you can detect the path used to generate given variant and re-use it later:, (*8)

use ChillDev\Spintax\Parser;

$path = [];

$spintax = Parser::parse('I {love {PHP|Java|C|C++|JavaScript|Python}|hate Ruby}.');
// since $path is empty, random values will be used for missing indices and $path will be filled with them
$string = $spintax->generate($path);

// from now you can use $path to re-create the same combination
// all these calls will keep returning same string value
$spintax->generate($path);
$spintax->generate($path);
$spintax->generate($path);
$spintax->generate($path);

// this will force generating "I love Java."
$path = [0, 1];
$spintax->generate($path);

Paths are counted from 0, each entry is next step., (*9)

You can also use partial paths to define just the starting path and all missing parts will be choosen randomly:, (*10)

use ChillDev\Spintax\Parser;

$path = [0];

$spintax = Parser::parse('I {love {PHP|Java|C|C++|JavaScript|Python}|hate Ruby}.');
// this will generate one of "I love {}." variants
$string = $spintax->generate($path);

For all this there is a shortcut method Parser::replicate() (you can use comma-separated number in a single string as second argument in this shortcut method):, (*11)

use ChillDev\Spintax\Parser;

echo Parser::replicate('I {love {PHP|Java|C|C++|JavaScript|Python}|hate Ruby}.', '0,0');

For more advanced aspects see advanced usage documentation or even internals description., (*12)

Resources

Contributing

Do you want to help improving this project? Simply fork it and post a pull request. You can do everything on your own, you don't need to ask if you can, just do all the awesome things you want!, (*13)

This project is published under MIT license., (*14)

Authors

ChillDevSpintax is brought to you by Chillout Development., (*15)

List of contributors:, (*16)

The Versions

24/01 2014

dev-master

9999999-dev http://chilloutdevelopment.github.com/ChillDevSpintax

Spintax {parsing|processing} library.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

seo chilldev spintax content generator

24/01 2014

0.0.1

0.0.1.0 http://chilloutdevelopment.github.com/ChillDevSpintax

Spintax {parsing|processing} library.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

seo chilldev spintax content generator