content[] = ''; } public function beginChildren() { $this->content[] = ''; } public function render($callback) { if (! is_callable($callback)) { throw new RuntimeException('Callable expected'); } foreach ($this as $node) { try { $content = call_user_func($callback, $node); } catch (Exception $e) { throw new RuntimeException($e); } $this->content[] = $content; } return implode("\n", $this->content); } }