Conditions | 6 |
Paths | 6 |
Total Lines | 29 |
Code Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
56 | public function sendHeaders() |
||
57 | { |
||
58 | if (empty($this->headers)) { |
||
59 | return; |
||
60 | } |
||
61 | |||
62 | $this->checkIfHeadersAlreadySent(); |
||
63 | |||
64 | foreach ($this->headers as $header) { |
||
65 | switch ($header) { |
||
66 | case '403': |
||
67 | header('HTTP/1.0 403 Forbidden'); |
||
68 | break; |
||
69 | |||
70 | case '404': |
||
71 | header('HTTP/1.0 404 Not Found'); |
||
72 | break; |
||
73 | |||
74 | case '500': |
||
75 | header('HTTP/1.0 500 Internal Server Error'); |
||
76 | break; |
||
77 | |||
78 | default: |
||
79 | throw new \Exception("Trying to sen unkown header type: '$header'."); |
||
80 | } |
||
81 | } |
||
82 | |||
83 | return $this; |
||
84 | } |
||
85 | |||
103 |
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.