/** * @dataProvider hyphenationOfSingleWordWithArrayOutputProvider */ public function testHyphenationOfSingleWordWithArrayOutput($word, $language, $expected) { $o = new h\Options(); $o->setHyphen('-')->setDefaultLocale($language)->setRightMin(2)->setLeftMin(2)->setWordMin(5)->setFilters('NonStandard')->setTokenizers('Whitespace', 'Punctuation'); $h = new h\Hyphenator(); $h->setOptions($o); $this->assertEquals($expected, $h->hyphenate($word)); }
public function testHyphenatorInvocationSimple() { $h = h\Hyphenator::factory(__DIR__ . '/share/test2', 'de_DE'); $this->assertInstanceof('\\Org\\Heigl\\Hyphenator\\Tokenizer\\TokenizerRegistry', $h->getTokenizers()); $t = $h->getTokenizers(); $this->assertAttributeEquals(array(new h\Tokenizer\WhitespaceTokenizer(), new h\Tokenizer\PunctuationTokenizer()), '_registry', $t); $this->assertEquals('Do-nau-dampf-schiff-fahrt', $h->hyphenate('Donaudampfschifffahrt')); $this->assertEquals('Gü-ter-mäd-chen', $h->hyphenate('Gütermädchen')); }
* @package Org_Heigl_Hyphenator * @author Andreas Heigl<*****@*****.**> * @copyright 2011-2011 Andreas Heigl * @license @__LICENSEURL__@ @__LICENSENAME__@ * @version 2.0.1 * @since 05.09.2011 */ // TODO: check include path ini_set('date.timezone', 'Europe/Berlin'); ini_set('memory_limit', '512M'); // Ensure library/ is on include_path set_include_path(implode(PATH_SEPARATOR, array(realpath(__DIR__ . '/../src'), get_include_path()))); require_once __DIR__ . '/../vendor/autoload.php'; mb_internal_encoding('UTF-8'); require_once 'Org/Heigl/Hyphenator/Hyphenator.php'; \Org\Heigl\Hyphenator\Hyphenator::registerAutoload(); class UnitTestHelper { /** * Access protected or private methods * * use the following code to access any protected or private class method * $obj = new MyClass(); * $method = UnitTestHelper::getMethod($obj, 'nameOfMethod'); * $result = $method->invoke($obj,'param1','param2'); * * @param Object|string $obj * @param string $name * * @return method */
public function fix($content, StateBag $stateBag = null) { return $this->hyphenator->hyphenate($content); }
echo '8' === $_REQUEST['wordMin'] ? 'selected="selected"' : ''; ?> value="8">8</option> </select> <label for="customHyphen">Custom Hyphen-String</label> <input type="text" name="customHyphen" value="<?php echo $_REQUEST['customHyphen']; ?> " /> </fieldset> <fieldset class="buttons"> <input type="submit" name="submit" value="Submit" /> <input type="reset" name="reset" value="Reset" /> </fieldset> </form> <div class="result"> <?php $hyphenator = \Org\Heigl\Hyphenator\Hyphenator::factory(null, $_REQUEST['language']); $hyphenator->getOptions()->setHyphen($_REQUEST['customHyphen'])->setLeftMin($_REQUEST['leftMin'])->setRightMin($_REQUEST['rightMin'])->setWordMin($_REQUEST['wordMin'])->setQuality($_REQUEST['quality']); $hyphenated = $hyphenator->hyphenate($_REQUEST['text']); echo '<span>' . $hyphenated . '</span>'; ?> </div> <div class="result"> <?php echo $_REQUEST['text']; ?> </div> </body> </html>