public function testTokenizingWithoutTokenizer() { $r = new TokenizerRegistry(); $tr = $r->tokenize('Teststring with spaces'); $this->assertInstanceof('\\Org\\Heigl\\Hyphenator\\Tokenizer\\TokenRegistry', $tr); }
/** * This method does the actual hyphenation. * * The given <var>$string</var> is splitted into chunks (i.e. Words) at * every blank. * * After that every chunk is hyphenated and the array of chunks is merged * into a single string using blanks again. * * This method does not take into account other word-delimiters than blanks * (eg. returns or tabstops) and it will fail with texts containing markup * in any way. * * @param string $string The string to hyphenate * * @return string The hyphenated string */ public function hyphenate($string) { $tokens = $this->_tokenizers->tokenize($string); $tokens = $this->getHyphenationPattern($tokens); $tokens = $this->filter($tokens); if (1 === sizeof($tokens) && 1 === $this->getFilters()->count()) { $tokens->rewind(); $return = $tokens->current()->getHyphenatedContent(); } else { $return = $this->getFilters()->concatenate($tokens); } return $return; }