/** * @param ThemeResource $resource * * @return string */ public function generate(ThemeResource $resource) { if ($resource->isType(\Documentor\ThemeResource::TYPE_CLASS)) { $file = 'class.phtml'; } elseif ($resource->isType(\Documentor\ThemeResource::TYPE_NAMESPACE)) { $file = 'namespace.phtml'; } elseif ($resource->isType(\Documentor\ThemeResource::TYPE_INDEX)) { $file = 'docindex.phtml'; } else { throw new \Documentor\Exception(sprintf('Invalid Theme Resource Type: %s', $resource->getType())); } $fullfile = rtrim($this->resourcesDir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $file; if (!is_file($fullfile)) { throw new \Documentor\Exception(sprintf('Invalid Theme Resource File: %s', $fullfile)); } ob_start(); include $fullfile; $contents = ob_get_clean(); return $contents; }