Exemple #1
0
 /**
  * Replace key in URL or string.
  * When replacing in URL instance method can be 'replace' or 'setGet'.
  * 
  * @param URL|string $url
  * @param string
  * @param string
  * @param string
  * @return type
  */
 protected function replaceUrl($url, $key, $value, $method = 'replace')
 {
     if ($url instanceof URL) {
         return $url->copy()->{$method}($key, $value);
     }
     return str_replace($key, $value, $url);
 }
Exemple #2
0
 /**
  * Set headers for redirect.
  * 
  * @param string|URL $url
  * @param int $code Header Code
  * @return self
  */
 public function redirect($url, $code = 302)
 {
     if ($url instanceof URL) {
         $url->full();
     }
     return $this->headerCode($code)->header('Location', (string) $url);
 }