Skip to content

Commit

Permalink
#2440 - Remove unused recursive url() method
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeckerson committed Nov 25, 2024
1 parent 2ed923a commit b22cf27
Showing 1 changed file with 1 addition and 44 deletions.
45 changes: 1 addition & 44 deletions src/Documentation/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,12 @@

namespace Zephir\Documentation;

use Zephir\Class\Definition\Definition;
use Zephir\CompilerFile;
use Zephir\Config;
use Zephir\Documentation;
use Zephir\Exception;

use function array_merge;
use function file_exists;
use function file_put_contents;
use function is_string;
use function ltrim;
use function ob_get_clean;
use function ob_start;

Expand All @@ -37,13 +32,6 @@ class Template
protected $themeOptions;

/**
* Template constructor.
*
* @param Theme $theme
* @param array $data
* @param string $template
* @param int $nestedLevel
*
* @throws Exception
*/
public function __construct(
Expand All @@ -58,9 +46,6 @@ public function __construct(
}
}

/**
* @return string
*/
public function getPathToRoot(): string
{
return $this->pathToRoot;
Expand Down Expand Up @@ -93,8 +78,6 @@ public function partial(string $fileName, array $data = [])

/**
* the path to root for the hyperlink in the templates.
*
* @param string $pathToRoot
*/
public function setPathToRoot(string $pathToRoot): void
{
Expand All @@ -113,38 +96,12 @@ public function setProjectConfig($projectConfig): void

/**
* add theme options to make them available during the render phase.
*
* @param array $themeOptions
*/
public function setThemeOptions($themeOptions): void
public function setThemeOptions(array $themeOptions): void
{
$this->themeOptions = $themeOptions;
}

/**
* Generate an url relative to the current directory.
*
* @param string $url the url we want to reach
*
* @return string the relative path to the url
*/
public function url(string $url): string
{
if (is_string($url)) {
if ('/' == $url[0]) {
return $this->getPathToRoot() . ltrim($url, '/');
} elseif (is_string($url)) {
return $url;
}
} elseif ($url instanceof Definition) {
return $this->url(Documentation::classUrl($url));
} elseif ($url instanceof CompilerFile) {
return $this->url(Documentation::classUrl($url->getClassDefinition()));
}

return '';
}

public function write($outputFile): void
{
$content = $this->parse();
Expand Down

0 comments on commit b22cf27

Please sign in to comment.