Conditions | 2 |
Paths | 2 |
Total Lines | 9 |
Code Lines | 5 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
26 | public function redirect(string $location, int $code = 301) |
||
27 | { |
||
28 | if (in_array($code, array_keys(Response::HTTP_STATUS_CODES))) { |
||
29 | $this->triggerRedirect($location, $code); |
||
30 | return true; |
||
31 | } |
||
32 | |||
33 | throw new InvalidArgumentException('Target url is invalid or status code is unknown'); |
||
34 | } |
||
35 | |||
53 | } |
An exit expression should only be used in rare cases. For example, if you write a short command line script.
In most cases however, using an
exit
expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.