1 | <?php |
||
16 | class Redirection |
||
17 | { |
||
18 | /* ----------------------------------------------------------------- |
||
19 | | Properties |
||
20 | | ----------------------------------------------------------------- |
||
21 | */ |
||
22 | |||
23 | /** @var string */ |
||
24 | protected $from; |
||
25 | |||
26 | /** @var string */ |
||
27 | protected $to; |
||
28 | |||
29 | /** @var int */ |
||
30 | protected $status; |
||
31 | |||
32 | /** @var \Illuminate\Routing\Route|null */ |
||
33 | protected $route; |
||
34 | |||
35 | /* ----------------------------------------------------------------- |
||
36 | | Constructor |
||
37 | | ----------------------------------------------------------------- |
||
38 | */ |
||
39 | |||
40 | /** |
||
41 | * Redirection constructor. |
||
42 | * |
||
43 | * @param string $from |
||
44 | * @param string $to |
||
45 | * @param int $status |
||
46 | */ |
||
47 | 84 | public function __construct(string $from, string $to, int $status) |
|
53 | |||
54 | /** |
||
55 | * Make a new redirection. |
||
56 | * |
||
57 | * @param string $from |
||
58 | * @param string $to |
||
59 | * @param int $status |
||
60 | * |
||
61 | * @return static |
||
62 | */ |
||
63 | 12 | public static function make(string $from, string $to, int $status = Response::HTTP_MOVED_PERMANENTLY) |
|
67 | |||
68 | /* ----------------------------------------------------------------- |
||
69 | | Getters & Setters |
||
70 | | ----------------------------------------------------------------- |
||
71 | */ |
||
72 | |||
73 | /** |
||
74 | * Get the old URL. |
||
75 | * |
||
76 | * @return string |
||
77 | */ |
||
78 | 84 | public function getFrom(): string |
|
82 | |||
83 | /** |
||
84 | * Set the old URL. |
||
85 | * |
||
86 | * @param string $from |
||
87 | * |
||
88 | * @return $this |
||
89 | */ |
||
90 | 84 | public function setFrom(string $from): self |
|
96 | |||
97 | /** |
||
98 | * Get the new URL. |
||
99 | * |
||
100 | * @return string |
||
101 | */ |
||
102 | 84 | public function getTo(): string |
|
106 | |||
107 | /** |
||
108 | * Set the new URL. |
||
109 | * |
||
110 | * @param string $to |
||
111 | * |
||
112 | * @return $this |
||
113 | */ |
||
114 | 84 | public function setTo(string $to): self |
|
120 | |||
121 | /** |
||
122 | * Get the status code. |
||
123 | * |
||
124 | * @return int |
||
125 | */ |
||
126 | 84 | public function getStatus(): int |
|
130 | |||
131 | /** |
||
132 | * Set the status. |
||
133 | * |
||
134 | * @param int $status |
||
135 | * |
||
136 | * @return $this |
||
137 | */ |
||
138 | 84 | public function setStatus(int $status): self |
|
144 | |||
145 | /** |
||
146 | * Get the route. |
||
147 | * |
||
148 | * @return \Illuminate\Routing\Route|null |
||
149 | */ |
||
150 | 60 | public function getRoute(): ?Route |
|
154 | |||
155 | /** |
||
156 | * Set the route. |
||
157 | * |
||
158 | * @param \Illuminate\Routing\Route $route |
||
159 | * |
||
160 | * @return $this |
||
161 | */ |
||
162 | 60 | public function setRoute(Route $route) |
|
168 | |||
169 | /** |
||
170 | * Get the resolved url. |
||
171 | * |
||
172 | * @return string |
||
173 | */ |
||
174 | 60 | public function getResolvedUrl(): string |
|
184 | } |
||
185 |