Пример #1
1
 public function testGetCount()
 {
     $part = TextGenerator::factory("[a|b|c]");
     $this->assertEquals(6, $part->getCount());
     $part = TextGenerator::factory("[a|b|c|d]");
     $this->assertEquals(24, $part->getCount());
     $part = TextGenerator::factory("[a|b|c|d|e]");
     $this->assertEquals(120, $part->getCount());
 }
Пример #2
0
 public function testCount()
 {
     $str = "1|2|3|4|5|{7|8|9}";
     $part = new XorPart($str);
     $part->getCount();
     $this->assertEquals(8, $part->getCount());
     $str = "1|2|3|4|5|[7|8|9]";
     $part = new XorPart($str);
     $part->getCount();
     $this->assertEquals(11, $part->getCount());
     $str = "{{1|2|3} {4|5|6}}";
     $part = TextGenerator::factory($str);
     $part->getCount();
     $this->assertEquals(9, $part->getCount());
     $str = "1|2|3|4|5|6";
     $part = new XorPart($str);
     $this->assertEquals(6, $part->getCount());
 }
Пример #3
0
 public function generateText($text, $id)
 {
     $textGeneratorOptions = array(Part::OPTION_GENERATE_HASH => $id);
     return TextGenerator::factory($text, $textGeneratorOptions)->generate();
 }
Пример #4
0
require_once LIBRARY_PATH . '/TextGenerator/TextGenerator.php';
?>
<!DOCTYPE html>
<html>
<head>
    <title>Seo generator demo</title>
    <meta charset='utf-8'>
    <meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
</head>
<body>
<form action="" method="POST">
    <label><textarea name="template" id="template" cols="100" rows="10">Генератор текста{ -|:} {скрипт, предназначенный|программа, предназначенная} для [+ и +генерации|создания] уникальных [ +, +описаний|названий|{анкоров|ссылок}].</textarea></label>
    <br>
    <input type="submit" value="Генерить!"/>
</form>

<?php 
if (isset($_POST['template'])) {
    $template = $_POST['template'];
    $t = microtime(true);
    $generator = \TextGenerator\TextGenerator::factory($template);
    for ($i = 0; $i < 5000; $i++) {
        echo '<br /><br />';
        echo $generator->generate();
    }
    echo '<br />------------------<br />';
    echo microtime(true) - $t;
}
?>
</body>
</html>
Пример #5
0
 public function testReplace()
 {
     $str = "Hi {%gender%} you are so [+ and +%type%]";
     TextGenerator::addReplaceList(['%gender' => 'female', 'type%' => 'cute']);
     $this->assertEquals("Hi female you are so cute", TextGenerator::factory($str)->generate());
 }