1 <?php
2
3 namespace Http\Message\UriFactory;
4
5 use Http\Message\UriFactory;
6 use Psr\Http\Message\UriInterface;
7 use Zend\Diactoros\Uri;
8
9 /**
10 * Creates Diactoros URI.
11 *
12 * @author David de Boer <david@ddeboer.nl>
13 */
14 final class DiactorosUriFactory implements UriFactory
15 {
16 /**
17 * {@inheritdoc}
18 */
19 public function createUri($uri)
20 {
21 if ($uri instanceof UriInterface) {
22 return $uri;
23 } elseif (is_string($uri)) {
24 return new Uri($uri);
25 }
26
27 throw new \InvalidArgumentException('URI must be a string or UriInterface');
28 }
29 }
30