1: <?php
2:
3: class Syllable_Hyphen_Entity implements Syllable_Hyphen_Interface {
4: private $entity;
5:
6: public function __construct($entity) {
7: $this->entity = $entity;
8: }
9:
10: public function joinText($parts) {
11: return join('&'.$this->entity.';', $parts);
12: }
13:
14: public function joinHtmlDom($parts, DOMNode $node) {
15: if (($p = count($parts)) > 1) {
16: $node->data = $parts[--$p];
17: while (--$p >= 0) {
18: $node = $node->parentNode->insertBefore($node->ownerDocument->createEntityReference($this->entity), $node);
19: $node = $node->parentNode->insertBefore($node->ownerDocument->createTextNode($parts[$p]), $node);
20: }
21: }
22: }
23:
24: public function stripHtml($html) {
25: return str_replace('&'.$this->entity.';', '', $html);
26: }
27: }