File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -206,6 +206,27 @@ public function getCode(): int
206206 return $ this ->code ;
207207 }
208208
209+ public function isRedirect (bool $ range_check = true ): bool
210+ {
211+ return self ::isRedirectFromCode ($ this ->code , $ range_check );
212+ }
213+
214+ public static function isRedirectFromCode (int $ code , bool $ range_check = true ): bool
215+ {
216+ switch ($ code )
217+ {
218+ case self ::HTTP_MULTIPLE_CHOICES :
219+ case self ::HTTP_MOVED_PERMANENTLY :
220+ case self ::HTTP_FOUND :
221+ case self ::HTTP_SEE_OTHER :
222+ case self ::HTTP_TEMPORARY_REDIRECT :
223+ case self ::HTTP_PERMANENT_REDIRECT :
224+ return true ;
225+ default :
226+ return $ range_check ? ($ code >= 300 && $ code < 400 ) : false ;
227+ }
228+ }
229+
209230 public function jsonSerialize (): mixed
210231 {
211232 return ['code ' => $ this ->code , 'name ' => self ::codeFromInt ($ this ->code )];
You can’t perform that action at this time.
0 commit comments