Skip to content

Commit

Permalink
Accepting coding standards
Browse files Browse the repository at this point in the history
Co-authored-by: Steve Boyd <emteknetnz@gmail.com>
  • Loading branch information
nathanbrauer and emteknetnz authored Nov 9, 2023
1 parent 88676bf commit f650627
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions src/Controllers/ShareDraftController.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@ class ShareDraftController extends Controller
*/
protected static $isViewingPreview = false;

/**
* @var array
*/
private $redirectRecursionIterations = [];
private array $redirectRecursionIterations = [];

/**
* @return bool
Expand Down Expand Up @@ -189,12 +186,12 @@ private function getRenderedPageByURL(string $url): HTTPResponse

if ($response->isRedirect()) {
if (in_array($url, $this->redirectRecursionIterations)) {
throw new \Exception("Infinite recursion detected.".$this->getRedirectRecursionIterationsLog($url));
throw new \Exception("Infinite recursion detected." . $this->getRedirectRecursionIterationsLog($url));
}

$this->redirectRecursionIterations[] = $url;
if (count($this->redirectRecursionIterations) >= 30) {
throw new \Exception("Max redirect recursions reached.".$this->getRedirectRecursionIterationsLog());
throw new \Exception("Max redirect recursions reached." . $this->getRedirectRecursionIterationsLog());
}

// The redirect will probably be Absolute URL so just want the path
Expand All @@ -206,15 +203,11 @@ private function getRenderedPageByURL(string $url): HTTPResponse
return $response;
}

/**
* @param string $append_url
* @return string
*/
protected function getRedirectRecursionIterationsLog(string $append_url=''): string
private function getRedirectRecursionIterationsLog(string $appendUrl= ''): string
{
return "\n\nRedirected URLs stack: \n"
. implode("\n", $this->redirectRecursionIterations)
. ($append_url ? "\n$append_url" : '');
. ($appendUrl ? "\n$appendUrl" : '');
}

/**
Expand Down

0 comments on commit f650627

Please sign in to comment.