private function getContentAsString($content) { if (is_string($content) || method_exists($content, '__toString')) { $content = (string) $content; return empty($content) ? FALSE : $content; } throw new \UnexpectedValueException('Invalid document fragment'); }