Skip to content

Commit

Permalink
Merge pull request #17 from madeITBelgium/analysis-22QaQA
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI
  • Loading branch information
madeITBelgium authored Jul 5, 2022
2 parents eb71d81 + 6e27223 commit 7208a2c
Showing 1 changed file with 25 additions and 19 deletions.
44 changes: 25 additions & 19 deletions src/Seo.php
Original file line number Diff line number Diff line change
Expand Up @@ -669,52 +669,56 @@ private function convertNumbers($string)
{
return strtr($string, ['۰' => '0', '۱' => '1', '۲' => '2', '۳' => '3', '۴' => '4', '۵' => '5', '۶' => '6', '۷' => '7', '۸' => '8', '۹' => '9']);
}

/** Build a URL

/**
* Build a URL.
*
* @param array $parts An array that follows the parse_url scheme
*
* @return string
*/
function build_url($parts)
public function build_url($parts)
{
if (empty($parts['user'])) {
$url = $parts['scheme'] . '://' . $parts['host'];
} elseif(empty($parts['pass'])) {
$url = $parts['scheme'] . '://' . $parts['user'] . '@' . $parts['host'];
$url = $parts['scheme'].'://'.$parts['host'];
} elseif (empty($parts['pass'])) {
$url = $parts['scheme'].'://'.$parts['user'].'@'.$parts['host'];
} else {
$url = $parts['scheme'] . '://' . $parts['user'] . ':' . $parts['pass'] . '@' . $parts['host'];
$url = $parts['scheme'].'://'.$parts['user'].':'.$parts['pass'].'@'.$parts['host'];
}

if (!empty($parts['port'])) {
$url .= ':' . $parts['port'];
$url .= ':'.$parts['port'];
}

if (!empty($parts['path'])) {
$url .= $parts['path'];
}

if (!empty($parts['query'])) {
$url .= '?' . $parts['query'];
$url .= '?'.$parts['query'];
}

if (!empty($parts['fragment'])) {
return $url . '#' . $parts['fragment'];
return $url.'#'.$parts['fragment'];
}

return $url;
}

/** Convert a relative path in to an absolute path
/**
* Convert a relative path in to an absolute path.
*
* @param string $path
*
* @return string
*/
function abs_path($path)
public function abs_path($path)
{
$path_array = explode('/', $path);

// Solve current and parent folder navigation
$translated_path_array = array();
$translated_path_array = [];
$i = 0;
foreach ($path_array as $name) {
if ($name === '..') {
Expand All @@ -724,16 +728,18 @@ function abs_path($path)
}
}

return '/' . implode('/', $translated_path_array);
return '/'.implode('/', $translated_path_array);
}

/** Convert a relative URL in to an absolute URL
/**
* Convert a relative URL in to an absolute URL.
*
* @param string $url URL or URI
* @param string $url URL or URI
* @param string $base Absolute URL
*
* @return string
*/
function abs_url($url, $base)
public function abs_url($url, $base)
{
$url_parts = parse_url($url);
$base_parts = parse_url($base);
Expand All @@ -743,9 +749,9 @@ function abs_url($url, $base)
// Is the path relative
if (substr($url_parts['path'], 0, 1) !== '/') {
if (substr($base_parts['path'], -1) === '/') {
$url_parts['path'] = $base_parts['path'] . $url_parts['path'];
$url_parts['path'] = $base_parts['path'].$url_parts['path'];
} else {
$url_parts['path'] = dirname($base_parts['path']) . '/' . $url_parts['path'];
$url_parts['path'] = dirname($base_parts['path']).'/'.$url_parts['path'];
}
}

Expand Down

0 comments on commit 7208a2c

Please sign in to comment.