composer package updates
[openemr.git] / vendor / zendframework / zend-diactoros / src / Response / RedirectResponse.php
blob800428cdb1f900dd6dfffabb35d23934ace4c540
1 <?php
2 /**
3 * Zend Framework (http://framework.zend.com/)
5 * @see http://github.com/zendframework/zend-diactoros for the canonical source repository
6 * @copyright Copyright (c) 2015-2016 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md New BSD License
8 */
10 namespace Zend\Diactoros\Response;
12 use InvalidArgumentException;
13 use Psr\Http\Message\UriInterface;
14 use Zend\Diactoros\Response;
16 use function get_class;
17 use function gettype;
18 use function is_object;
19 use function is_string;
20 use function sprintf;
22 /**
23 * Produce a redirect response.
25 class RedirectResponse extends Response
27 /**
28 * Create a redirect response.
30 * Produces a redirect response with a Location header and the given status
31 * (302 by default).
33 * Note: this method overwrites the `location` $headers value.
35 * @param string|UriInterface $uri URI for the Location header.
36 * @param int $status Integer status code for the redirect; 302 by default.
37 * @param array $headers Array of headers to use at initialization.
39 public function __construct($uri, $status = 302, array $headers = [])
41 if (! is_string($uri) && ! $uri instanceof UriInterface) {
42 throw new InvalidArgumentException(sprintf(
43 'Uri provided to %s MUST be a string or Psr\Http\Message\UriInterface instance; received "%s"',
44 __CLASS__,
45 (is_object($uri) ? get_class($uri) : gettype($uri))
46 ));
49 $headers['location'] = [(string) $uri];
50 parent::__construct('php://temp', $status, $headers);