Completed
Pull Request — master (#5)
by Márk
07:08
created

DiactorosUriFactory::createUri()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 10
ccs 0
cts 9
cp 0
rs 9.4286
cc 3
eloc 6
nc 3
nop 1
crap 12
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 <[email protected]>
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