Source of file Redirect.php
Size: 1,395 Bytes - Last Modified: 2021-12-24T06:51:21+00:00
/var/www/docs.ssmods.com/process/src/src/Redirect.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 | <?php namespace Heyday\SilverStripeRedirects\Source; /** * Class Redirect * @package Heyday\SilverStripeRedirects\Source */ class Redirect { /** @var string */ protected $from; /** @var string */ protected $to; /** @var int */ protected $statusCode; /** * @param string $from * @param string $to * @param int $statusCode */ public function __construct($from, $to, $statusCode = 301) { $this->from = $from; $this->to = $to; $this->statusCode = $statusCode; } /** * @return string */ public function getFrom() { return $this->from; } /** * @return string */ public function getTo() { return $this->to; } /** * @return int */ public function getStatusCode() { return ((isset($this->statusCode) && !empty($this->statusCode)) ? $this->statusCode : 301); } /** * @param string $url * @return bool */ public function match($url) { $from = self::formatUrl($this->from); return (($from === self::formatUrl($url)) && ($from !== self::formatUrl($this->to))); } /** * @param string $url * @return string */ public static function formatUrl($url) { return trim( strtolower($url), '/' ); } } |