| Conditions | 3 |
| Paths | 2 |
| Total Lines | 18 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 17 | public function retrieveHeader($url) { |
||
| 18 | $this->setContext(); |
||
| 19 | |||
| 20 | // get_headers already follows redirects and stacks headers up in array |
||
| 21 | $headers = @get_headers($url, TRUE); |
||
| 22 | $headers = array_change_key_case($headers); |
||
| 23 | |||
| 24 | // if there were multiple redirects flatten down the location header |
||
| 25 | if (isset($headers['location']) && is_array($headers['location'])) { |
||
| 26 | $headers['location'] = array_filter($headers['location'], function ($header) { |
||
| 27 | return strpos($header, '://') !== false; // leave only absolute urls |
||
| 28 | }); |
||
| 29 | |||
| 30 | $headers['location'] = end($headers['location']); |
||
| 31 | } |
||
| 32 | |||
| 33 | return $headers; |
||
| 34 | } |
||
| 35 | |||
| 56 | } |