Completed
Pull Request — master (#2)
by Márk
02:43
created

DiactorosUriFactory::createUri()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 10
ccs 6
cts 6
cp 1
rs 9.4286
cc 3
eloc 6
nc 3
nop 1
crap 3
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 3
    public function createUri($uri)
20
    {
21 3
        if ($uri instanceof UriInterface) {
22 1
            return $uri;
23 2
        } elseif (is_string($uri)) {
24 1
            return new Uri($uri);
25
        }
26
27 1
        throw new \InvalidArgumentException('URI must be a string or UriInterface');
28
    }
29
}
30